Skip to contentSkip to conversation

reparent_thread: fix the "is it traced" check

PATCH In review Oleg Nesterov 2 participants 2 messages Jan 29, 2009 – Feb 5, 2009

lore
Share & tools
lore
#0 lore raw

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);
 
Acked-by on v1 2/4
#1 lore raw
Quoted 2 lines

reparent_thread() uses ptrace_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, because forget_original_parent() has already changed ->real_parent.

Heh. Ok. I think the !p->ptrace check is fine.

Thanks,
Roland