lkml.org 
[lkml]   [1997]   [Mar]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subjectfork bomb protection patch, 2.1.30

i'm posting now from a kernel with the fork bomb patch enabled:

------------------------------------------------------------------->
pc5829:~/forkbomb$ cat bomb
bash: fork: Try again
pc5829:~/forkbomb$ cat bomb
#!/bin/bash

bomb &
bomb &

pc5829:~/forkbomb$ uptime
2:12pm up 28 min, 3 users, load average: 225.53, 169.94, 84.59
<------------------------------------------------------------------

the system is noticably slower, but it's still quite usable :) The patch
fixes other scheduling oddities as well, i hope it's the right thing ...

It's against 2.1.30, but it should work in 2.0 too.

-- mingo

--- linux-2.1.30_vanilla/kernel/fork.c Sun Jan 26 12:40:46 1997
+++ linux/kernel/fork.c Sat Mar 29 14:17:13 1997
@@ -292,7 +298,16 @@
/* ok, now we should be set up.. */
p->swappable = 1;
p->exit_signal = clone_flags & CSIGNAL;
- p->counter = current->counter >> 1;
+
+ /*
+ * "share" dynamic priority between parent and child, thus the
+ * total amount of dynamic priorities in the system doesnt change,
+ * more scheduling fairness. This is only important in the first
+ * timeslice, on the long run the scheduling behaviour is unchanged.
+ */
+ current->counter >>= 1;
+ p->counter = current->counter;
+
if(p->pid) {
wake_up_process(p); /* do this last, just in case */
} else {

\
 
 \ /
  Last update: 2005-03-22 13:39    [W:0.040 / U:0.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site