diff options
author | Tejun Heo <tj@kernel.org> | 2011-02-10 15:01:22 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-03-21 12:44:54 -0700 |
commit | edf07481f5a833b01bf23910834133fdac72fde1 (patch) | |
tree | 919e29b01127a92ceaa1f1e9283434182f9437b0 | |
parent | 0769e495f2a53ac6e1e52b1a5954a1f90b52c3d2 (diff) | |
download | kernel-common-edf07481f5a833b01bf23910834133fdac72fde1.tar.gz kernel-common-edf07481f5a833b01bf23910834133fdac72fde1.tar.bz2 kernel-common-edf07481f5a833b01bf23910834133fdac72fde1.zip |
ptrace: use safer wake up on ptrace_detach()
commit 01e05e9a90b8f4c3997ae0537e87720eb475e532 upstream.
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 state.
This bug can possibly be used as an attack vector. I don't think it
will take too much effort to come up with an attack which triggers oops
somewhere. Most sleeps are wrapped in condition test loops and should
be safe but we have quite a number of places where sleep and wakeup
conditions are expected to be interlocked. Although the window of
opportunity is tiny, ptrace can be used by non-privileged users and with
some loading the window can definitely be extended and exploited.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Roland McGrath <roland@redhat.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | kernel/ptrace.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 23bd09cd042e..05625f6c2293 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -314,7 +314,7 @@ int ptrace_detach(struct task_struct *child, unsigned int data) 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); } write_unlock_irq(&tasklist_lock); |