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;
ulimit -u ?
ulimit -u ?
In Kernel Code
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"
IIRC max_threads is a "high" hardcoded value
nr_threads
What is nr_threads ? Is it a local variable in fork.c? where does it get initialized ?