[PATCH] Prevent max_threads from exceeding PID_MAX

From: Patrick O'Rourke (porourke@egenera.com)
Date: Thu Mar 07 2002 - 15:45:17 EST


It is possible on large memory systems that the default process limits
can exceed PID_MAX. This will allow a non-root user to consume all pids
resulting in the kernel to basically hang in get_pid().

The following patch to fork_init() will prevent max_threads from exceeding
PID_MAX.

Pat

--- linux-2.4.19-pre2-x/kernel/fork.c Mon Feb 25 14:38:13 2002
+++ linux-2.4.19-pre2/kernel/fork.c Wed Mar 6 09:15:17 2002
@@ -74,6 +74,11 @@
          */
         max_threads = mempages / (THREAD_SIZE/PAGE_SIZE) / 8;
 
+ /* don't let threads go beyond PID_MAX */
+ if (max_threads > PID_MAX) {
+ max_threads = PID_MAX;
+ }
+
         init_task.rlim[RLIMIT_NPROC].rlim_cur = max_threads/2;
         init_task.rlim[RLIMIT_NPROC].rlim_max = max_threads/2;
 }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Mar 07 2002 - 21:01:08 EST