* [PATCH] wait4 PTRACE_ATTACH race fix
@ 2005-10-11 5:05 Roland McGrath
0 siblings, 0 replies; only message in thread
From: Roland McGrath @ 2005-10-11 5:05 UTC (permalink / raw)
To: Andrew Morton, Linus Torvalds; +Cc: linux-kernel
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>
--- linux-2.6/kernel/exit.c
+++ linux-2.6/kernel/exit.c
@@ -1370,6 +1370,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*/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-10-11 5:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-11 5:05 [PATCH] wait4 PTRACE_ATTACH race fix Roland McGrath
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®