diff options
author | Roland McGrath <roland@redhat.com> | 2005-10-31 00:02:50 +0100 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-10-31 02:37:24 +0100 |
commit | 7f2a52555998c699a7e89f24636c909d6fc08a60 (patch) | |
tree | 98ef1254ab3e727ba3470d4eeaf064d5dcb48614 /kernel | |
parent | [PATCH] ioc4 serial support - mostly cleanup (diff) | |
download | linux-7f2a52555998c699a7e89f24636c909d6fc08a60.tar.xz linux-7f2a52555998c699a7e89f24636c909d6fc08a60.zip |
[PATCH] wait4 PTRACE_ATTACH race fix
Back about a year ago when I last fiddled heavily with the do_wait code, I
was thinking too hard about the wrong thing and I now think I introduced a
bug whose inverse thought I was fixing.
Apparently noone was looking too hard over much shoulder, so as to cite my
bogus reasoning at the time. In the race condition when PTRACE_ATTACH is
about to steal a child and then the child hits a tracing event (what
my_ptrace_child checks for), the real parent does need to set its flag
noting it has some eligible live children. Otherwise a spurious ECHILD
error is possible, since the child in question is not yet on the
ptrace_children list.
Signed-off-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/exit.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index 6ef8f7356a74..2d39ccc367e6 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -1383,6 +1383,15 @@ repeat: switch (p->state) { case TASK_TRACED: + /* + * When we hit the race with PTRACE_ATTACH, + * we will not report this child. But the + * race means it has not yet been moved to + * our ptrace_children list, so we need to + * set the flag here to avoid a spurious ECHILD + * when the race happens with the only child. + */ + flag = 1; if (!my_ptrace_child(p)) continue; /*FALLTHROUGH*/ |