[lkml]   [2011]   [Feb]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] ptrace: use safer wake up on ptrace_detach()
The wake_up_process() call in ptrace_detach() is spurious and not
interlocked with the tracee state. IOW, the tracee could be running
or sleeping in any place in the kernel by the time wake_up_process()
is called. This can lead to the tracee waking up unexpectedly which
can be dangerous.

The wake_up is spurious and should be removed but for now reduce its
toxicity by only waking up if the tracee is in TRACED or STOPPED

Signed-off-by: Tejun Heo <>
Cc: Roland McGrath <>
Cc: Oleg Nesterov <>
So, something like this. Roland, Oleg, can you guys please ack this?
Also, should these ptrace patches be routed? Shall I set up a git

Thank you.

kernel/ptrace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: work/kernel/ptrace.c
--- work.orig/kernel/ptrace.c
+++ work/kernel/ptrace.c
@@ -313,7 +313,7 @@ int ptrace_detach(struct task_struct *ch
child->exit_code = data;
dead = __ptrace_detach(current, child);
if (!child->exit_state)
- wake_up_process(child);
+ wake_up_state(child, TASK_TRACED | TASK_STOPPED);

 \ /
  Last update: 2011-02-01 11:29    [W:0.184 / U:0.568 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site