archive mirror
 help / color / mirror / Atom feed
* [PATCH] saner limit for max_threads
@ 2001-06-18  2:11 Rik van Riel
  0 siblings, 0 replies; only message in thread
From: Rik van Riel @ 2001-06-18  2:11 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Alan Cox, linux-kernel


by default the limit for max_threads is such that
the system will try to allocate up to half the
physical memory in task_structs.

Because for each 8kB task struct we'll often want
a struct_mm, a page directory, 3 page tables and
some more structures, this means that a fork bomb
will leave the box DEAD with root never ever getting
a chance of using his reserved tasks and killing the
bad user.

The patch below adjusts the max_threads calculation
to something which should be more sane, though quite
possibly still to high...

Please apply for the next -pre kernel.



--- linux-2.4.6-pre3/kernel/fork.c.orig	Sun Jun 17 20:45:54 2001
+++ linux-2.4.6-pre3/kernel/fork.c	Sun Jun 17 23:07:20 2001
@@ -70,7 +70,7 @@
 	 * value: the thread structures can take up at most half
 	 * of memory.
-	max_threads = mempages / (THREAD_SIZE/PAGE_SIZE) / 2;
+	max_threads = mempages / (THREAD_SIZE/PAGE_SIZE) / 16;
 	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] only message in thread

only message in thread, other threads:[~2001-06-18  2:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-18  2:11 [PATCH] saner limit for max_threads Rik van Riel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).