reparent_thread: fix the "is it traced" check
PATCH 2/4 reparent_thread: fix the "is it traced" check
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.
kernel/exit.c renamed from kernel/exit.c~6_FIX_PTRACE_CHECK +1 -1
@@ -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);
Quoted 2 lines
reparent_thread()usesptrace_reparented()to check whether this thread is ptraced, in that case we should not notify the new parent.
I think at some point in the past, ptracedness could sometimes transfer to the new parent, so this made sense then (before it had that name).
Quoted 3 lines
But
ptrace_reparented()is not exactly correct when the reparented thread is traced by/sbin/init, becauseforget_original_parent()has already changed ->real_parent.
Heh. Ok. I think the !p->ptrace check is fine.
Thanks,
Roland