ptrace: give more respect to SIGKILL
authorOleg Nesterov <oleg@tv-sign.ru>
Fri, 25 Jul 2008 08:47:36 +0000 (01:47 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 25 Jul 2008 17:53:39 +0000 (10:53 -0700)
ptrace_stop() has some complicated checks to prevent the scheduling in the
TASK_TRACED state with the pending SIGKILL, but these checks are racy, and
they depend on arch_ptrace_stop_needed().

This patch assumes that the traced task should die asap if it was killed by
SIGKILL, in that case schedule()->signal_pending_state() has no reason to
ignore the TASK_WAKEKILL part of TASK_TRACED, and we can kill this nasty
special case.

Note: do_exit()->ptrace_notify() is special, the killed task can already
dequeue SIGKILL at this point. Another indication that fatal_signal_pending()
is not exactly right.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/sched.h

index 6aca4a16e377633a1d2cde29fba627b086241b0a..79e749dbf81e151dc1e40d79ab8268bc9d813d2f 100644 (file)
@@ -2054,9 +2054,6 @@ static inline int signal_pending_state(long state, struct task_struct *p)
        if (!signal_pending(p))
                return 0;
 
-       if (state & (__TASK_STOPPED | __TASK_TRACED))
-               return 0;
-
        return (state & TASK_INTERRUPTIBLE) || __fatal_signal_pending(p);
 }