aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@tv-sign.ru>2008-02-08 07:19:00 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-08 12:22:26 -0500
commit6405f7f4675884b671bee66678e1c2859bdb0e56 (patch)
tree31f0e42b011de36976f5a50b86aee7132f6b82b4 /kernel
parentc0c0b649d67aa775aa9851de61aade17504be70c (diff)
ptrace_stop: fix the race with ptrace detach+attach
If the tracer went away (may_ptrace_stop() failed), ptrace_stop() drops tasklist and then changes the ->state from TASK_TRACED to TASK_RUNNING. This can fool another tracer which attaches to us in between. Change the ->state under tasklist_lock to ensure that ptrace_check_attach() can't wrongly succeed. Also, remove the unnecessary mb(). Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Acked-by: Roland McGrath <roland@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/signal.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/kernel/signal.c b/kernel/signal.c
index 6d6d1ab39e7e..678bffa437c1 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1638,11 +1638,11 @@ static void ptrace_stop(int exit_code, int nostop_code, siginfo_t *info)
1638 } else { 1638 } else {
1639 /* 1639 /*
1640 * By the time we got the lock, our tracer went away. 1640 * By the time we got the lock, our tracer went away.
1641 * Don't stop here. 1641 * Don't drop the lock yet, another tracer may come.
1642 */ 1642 */
1643 read_unlock(&tasklist_lock); 1643 __set_current_state(TASK_RUNNING);
1644 set_current_state(TASK_RUNNING);
1645 current->exit_code = nostop_code; 1644 current->exit_code = nostop_code;
1645 read_unlock(&tasklist_lock);
1646 } 1646 }
1647 1647
1648 /* 1648 /*