Fork Bomb and why it doesn't happen on BSDs

Jeff Vian jvian10 at charter.net
Sat Mar 26 09:45:46 UTC 2005


On Fri, 2005-03-25 at 11:54 +0800, Ow Mun Heng wrote:
> On Fri, 2005-03-25 at 10:28 +0800, Ow Mun Heng wrote:
> > On Thu, 2005-03-24 at 14:11 -0600, Aleksandar Milivojevic wrote:
> > > William Hooper wrote:
> > > > Ow Mun Heng said:
> > > > [snip]
> > > > 
> > > >>The author then compares the results with that of BSD eg: OpenBSD and
> > > >>FreeBSD IIRC, and notes that on a system with Pentium 90 w/ 32MB Ram, on
> > > >>using the forkbomb, doesn't bring the system down to it's knees.
> > > > 
> > > > 
> > > > Following the discussion on the -devel list, the BSDs aren't immune.
> > > > 
> > > > https://www.redhat.com/archives/fedora-devel-list/2005-March/msg01201.html
> > > 
> > > I gave a try to "while(1) fork();" on OpenBSD (SS5, 64MB RAM).  You 
> > > can't go much simpler than that.  Results:
> > > 
> > > Running as normal user, max number of processes is limited to 64 by 
> > > default, load average went to 50-something.  Perfectly able to kill 
> > > offending process(es).
> > > 
> > > Running as root, max number of processes is limited to 340, load average 
> > > went to almost 300.  Not able to do much, since root couldn't create any 
> > > new processes (in order to kill existing), but top worked, and already 
> > > running processes worked.  Anyhow, if somebody does fork bomb as root, 
> > > he could just as well type "halt" or wipe out the disk or do some other 
> > > irreversable damage.
> > > 
> > > The maximum number of processes per user is hard coded in OpenBSD 
> > > kernel.  It is 340 for root, and 64/128 for normal users in my generic 
> > > kernel (soft limit is 64, hard limit is 128).  If you want more either 
> > > for root or normal users, you need to recompile the kernel.  In *BSD 
> > > world, recompiling the kernel is something you do twice a day anyhow, so 
> > > this isn't much of a problem ;-)
> > > 
> > > For those interested, these are ulimits on stock OpenBSD (user and root, 
> > > soft and hard).
> > > 
> > [SNIP]
> > 
> > I see.. So, ulimits _are_ set by default(lower) in *BSDs and not as what
> > I thought that they had some kind of process watchdog in place.
> > 
> 
> One more thing, what about if there are 20 users and all the 20 users
> try to fork at the same time? What will happen then?
> 

Obviously each will fork to his maximum limit unless the system process
table fills up or the whole system grinds to a halt due to
load/resource contention.





More information about the fedora-list mailing list