Skip to content

Commit

Permalink
kernel/signal.c: protect the traced SIGNAL_UNKILLABLE tasks from SIGKILL
Browse files Browse the repository at this point in the history
The comment in sig_ignored() says "Tracers may want to know about even
ignored signals" but SIGKILL can not be reported to debugger and it is
just wrong to return 0 in this case: SIGKILL should only kill the
SIGNAL_UNKILLABLE task if it comes from the parent ns.

Change sig_ignored() to ignore ->ptrace if sig == SIGKILL and rely on
sig_task_ignored().

SISGTOP coming from within the namespace is not really right too but at
least debugger can intercept it, and we can't drop it here because this
will break "gdb -p 1": ptrace_attach() won't work.  Perhaps we will add
another ->ptrace check later, we will see.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Oleg Nesterov <[email protected]>
Tested-by: Kyle Huey <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
oleg-nesterov authored and torvalds committed Nov 18, 2017
1 parent eecd7f4 commit 628c1bc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ static int sig_ignored(struct task_struct *t, int sig, bool force)
if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig))
return 0;

if (!sig_task_ignored(t, sig, force))
return 0;

/*
* Tracers may want to know about even ignored signals.
* Tracers may want to know about even ignored signal unless it
* is SIGKILL which can't be reported anyway but can be ignored
* by SIGNAL_UNKILLABLE task.
*/
return !t->ptrace;
if (t->ptrace && sig != SIGKILL)
return 0;

return sig_task_ignored(t, sig, force);
}

/*
Expand Down

0 comments on commit 628c1bc

Please sign in to comment.