[PATCH 2/4] reparent_thread: fix the "is it traced" check

From: Oleg Nesterov
Date: Thu Jan 29 2009 - 03:08:45 EST


reparent_thread() uses ptrace_reparented() to check whether this thread
is ptraced, in that case we should not notify the new parent.

But ptrace_reparented() is not exactly correct when the reparented thread
is traced by /sbin/init, because forget_original_parent() has already
changed ->real_parent.

Currently, the only problem is the false notification. But with the next
patch the kernel crash in this (yes, pathological) case.

Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx>

--- 6.29-rc3/kernel/exit.c~6_FIX_PTRACE_CHECK 2009-01-29 06:21:51.000000000 +0100
+++ 6.29-rc3/kernel/exit.c 2009-01-29 06:57:09.000000000 +0100
@@ -826,7 +826,7 @@ static void reparent_thread(struct task_
/* If we'd notified the old parent about this child's death,
* also notify the new parent.
*/
- if (!ptrace_reparented(p) &&
+ if (!p->ptrace &&
p->exit_state == EXIT_ZOMBIE && thread_group_empty(p))
do_notify_parent(p, p->exit_signal);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/