projects/linux·commit 04ec93fe

fork.c: fix NULL pointer dereference when nr_threads == threads-max

04ec93fe · Li Zefan <[email protected]> · 2009-02-06 08:17:19 +00:00

I happened to forked lots of processes, and hit NULL pointer dereference.
It is because in copy_process() after checking max_threads, 0 is returned
but not -EAGAIN.

The bug is introduced by "CRED: Detach the credentials from task_struct"
(commit f1752eec6145c97163dbce62d17cf5d928e28a27).

Signed-off-by: Li Zefan <[email protected]>
Signed-off-by: David Howells <[email protected]>
Acked-by: James Morris <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Commit
04ec93fe9bc98e3bd8560f79f56fed66dfae40d5
Parents
b2a740aa

Changes

1 files changed · +1 −0

FileStatusAddDelContent
kernel/fork.cmodified+1−0View file

kernel/fork.c

View file
diff --git a/kernel/fork.c b/kernel/fork.c
index 242a706..6d5dbb7 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1005,6 +1005,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
* triggers too late. This doesn't hurt, the check is only there
* to stop root fork bombs.
*/
+ retval = -EAGAIN;
if (nr_threads >= max_threads)
goto bad_fork_cleanup_count;