public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Prevent max_threads from exceeding PID_MAX
@ 2002-03-07 20:45 Patrick O'Rourke
  2002-03-07 22:11 ` Paul Larson
  0 siblings, 1 reply; 5+ messages in thread
From: Patrick O'Rourke @ 2002-03-07 20:45 UTC (permalink / raw)
  To: linux-kernel

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;
 }

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-03-08 15:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-03-07 20:45 [PATCH] Prevent max_threads from exceeding PID_MAX Patrick O'Rourke
2002-03-07 22:11 ` Paul Larson
2002-03-07 22:23   ` [PATCH] Fix for get_pid hang Paul Larson
2002-03-07 22:25   ` Paul Larson
2002-03-08 15:02     ` Patrick O'Rourke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox