ptrace_stop: fix the race with ptrace detach+attach
commit6405f7f4675884b671bee66678e1c2859bdb0e56
authorOleg Nesterov <oleg@tv-sign.ru>
Fri, 8 Feb 2008 12:19:00 +0000 (8 04:19 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Fri, 8 Feb 2008 17:22:26 +0000 (8 09:22 -0800)
tree31f0e42b011de36976f5a50b86aee7132f6b82b4
parentc0c0b649d67aa775aa9851de61aade17504be70c
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>
kernel/signal.c