Fork Bombs

Submitted by arunjoseph
on December 31, 2008 - 11:44am

I would like to know whether there is any mechanisms in linux kernel to prevent fork bombs.

ulimit -u ?

Anonymous (not verified)
on
December 31, 2008 - 12:46pm

ulimit -u ?

In Kernel Code

on
December 31, 2008 - 1:22pm

I have seen a code fragment in copy_process() function used by do_fork().(/kernel/sched.c)
These comments are indicating someway to automatically prevent fork bomb.
But I couldnt able to understand how does this prevention happens.

atomic_inc(&p->user->__count);
950 atomic_inc(&p->user->processes);
951 get_group_info(p->group_info);
952
953 /*
954 * If multiple threads are within copy_process(), then this check
955 * triggers too late. This doesn't hurt, the check is only there
956 * to stop root fork bombs.
957 */
958 if (nr_threads >= max_threads)
959 goto bad_fork_cleanup_count;

IIRC max_threads is a "high"

Anonymous (not verified)
on
January 1, 2009 - 5:55am

IIRC max_threads is a "high" hardcoded value

nr_threads

on
January 1, 2009 - 11:43am

What is nr_threads ? Is it a local variable in fork.c? where does it get initialized ?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.