]> pilppa.com Git - linux-2.6-omap-h63xx.git/commit
ptrace_stop: fix racy nonstop_code setting
authorOleg Nesterov <oleg@tv-sign.ru>
Fri, 8 Feb 2008 12:19:03 +0000 (04:19 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Fri, 8 Feb 2008 17:22:26 +0000 (09:22 -0800)
commit20686a309aa98c518adbbd9b57cdbb1804143deb
tree4aac811e67d777d3c0015ca51312aa93b4832d35
parent9cbab8100538efdd93aeae6fc37787d986f2f558
ptrace_stop: fix racy nonstop_code setting

If the tracer is gone and we are not going to stop, ptrace_stop() sets
->exit_code = nostop_code.  However, the tracer could actually clear the
exit code before detaching.  In that case get_signal_to_deliver() "resends"
the signal which was cancelled by the debugger.  For example, it is
possible that a quick PTRACE_ATTACH + PTRACE_DETACH can leave the tracee in
STOPPED state.

Change the behaviour of ptrace_stop().  If the caller is ptrace notify(),
we should always clear ->exit_code.  If the caller is
get_signal_to_deliver(), we should not touch it at all.  To do so, change
the nonstop_code parameter to "bool clear_code" and change the callers
accordingly.

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