Resource controls against fork bombs executed inside Solaris Zones

I came across this neat little tidbit on page 27 while reading through the pdf article UNDERSTANDING THE SECURITY CAPABILITIES OF SOLARIS™ ZONES SOFTWARE

As a test, I’m going to set this resource control on a zone and execute a fork bomb to see what appears in system logs.  This is pretty cool stuff! 

Miscellaneous Controls
One well-known method to over-consume system resources is a fork-bomb. This method does not necessarily consume a great deal of memory or CPU resources, but rather seeks to use up all of the process slots in the kernel’s process table. In the Solaris OS, a running process starts with just one thread of execution, also called a Light Weight Process (LWP). Many programs generate new threads, becoming multithreaded processes. By default, Solaris systems with a 64-bit kernel can run over 85,000 LWPs simultaneously. A booted zone that is not yet running any applications has approximately 100 to 150 LWPs. To prevent a zone from using too many LWPs, a limit can be set on their use. The following command sets a limit of 300 LWPs for a zone.
global# zonecfg -z web
zonecfg:web> set max-lwps=300
zonecfg:web> exit
global# zoneadm -z web reboot
 
 
 This parameter can be used, but should not be set so low that it impacts normal application operation. An accurate baseline for the number of LWPs for a given zone should be determined in order to set this valuable at an appropriate level. The number of LWPs used by a zone can be monitored using the following prstat command.
In this example, the web zone currently has 108 LWPs. This value changes as processes are created or exit. It should be inspected over a period of time in order to establish a more reliable baseline, and updated when the software, requirements, or workload change.
Using the max-lwps resource control successfully usually requires the use of a CPU control, such as the FSS or pools to ensure that there is enough CPU power in the global zone for the platform administrator to fix any problems that might arise.
 
global# prstat -LZ
[…]
ZONEID NLWP SWAP RSS MEMORY TIME CPU ZONE
0 248 468M 521M 8.6% 0:14:18 0.0% global
37 108 76M 61M 1.0% 0:00:00 0.0% web
Total: 122 processes, 356 lwps, load averages: 0.00, 0.00, 0.01

Leave a Reply

Your email address will not be published. Required fields are marked *