ptrace_resume->wake_up_process (Was: Ptrace documentation, draft#1)

From: Oleg Nesterov
Date: Mon May 23 2011 - 10:12:12 EST

On 05/23, Oleg Nesterov wrote:
> "does nothing" is not 100% true, it does wake_up_process() but this shouldn't
> be documented, this should be fixed.

In fact ptrace_resume()->wake_up_process() is obviously wrong anyway,
I think the patch below makes sense even for 2.6.40.

But it is much worse in PTRACE_KILL case. Just for example,

int main(void)
int child, status;

child = fork();
if (!child) {
int ret;

assert(ptrace(PTRACE_TRACEME, 0,0,0) == 0);

ret = pause();
printf("pause: %d %m\n", ret);

return 0x23;

assert(ptrace(PTRACE_KILL, child, 0,0) == 0);

assert(child == wait(&status));
printf("wait: %x\n", status);

return 0;

leaks -ERESTARTNOHAND. Yes, we should probably fix sys_pause() as well,
it should check signal_pending(). But we shouldn't allow to wake up the
tracee in unknown state/path.

Can't understand why this wasn't fixed before... I always knew this looks
wrong, but I never sent the patch. Probably because I never understood
the original reason for wake_up_process...


--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -706,7 +706,7 @@ static int ptrace_resume(struct task_str

child->exit_code = data;
- wake_up_process(child);
+ wake_up_state(child, TASK_TRACED);

return 0;

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at