fork.c: fix NULL pointer dereference when nr_threads == threads-max
Subsystems (3)
PATCH 1/1 fork.c: fix NULL pointer dereference when nr_threads == threads-max
From: Li Zefan <[email protected]>
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 this patch:
| commit f1752eec6145c97163dbce62d17cf5d928e28a27 | Author: David Howells <[email protected]> | Date: Fri Nov 14 10:39:17 2008 +1100 | | CRED: Detach the credentials from task_struct
Signed-off-by Li Zefan <[email protected]>
Signed-off-by David Howells <[email protected]>
---
kernel/fork.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
kernel/fork.c +1 -0
@@ -1007,6 +1007,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;
Quoted 8 lines · David Howells
From: Li Zefan <[email protected]>
I happened to forked lots of processes, and hit NULL pointer dereference. It is because in
copy_process()after checkingmax_threads, 0 is returned but not-EAGAIN.The bug is introduced by this patch:
Quoted 8 lines
| commit f1752eec6145c97163dbce62d17cf5d928e28a27 | Author: David Howells <[email protected]> | Date: Fri Nov 14 10:39:17 2008 +1100 | | CRED: Detach the credentials from task_structSigned-off-by Li Zefan <[email protected]>Signed-off-by David Howells <[email protected]>
Acked-by James Morris <[email protected]>
Quoted 19 lines
---
kernel/fork.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)kernel/fork.c +1
-0@@ -1007,6 +1007,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;
Signature · 2 lines
James Morris <[email protected]>