Skip to content

Commit

Permalink
signals: protect init from unwanted signals more
Browse files Browse the repository at this point in the history
(This is a modified version of the patch submitted by Oleg Nesterov
http://lkml.org/lkml/2008/11/18/249 and tries to address comments that
came up in that discussion)

init ignores the SIG_DFL signals but we queue them anyway, including
SIGKILL.  This is mostly OK, the signal will be dropped silently when
dequeued, but the pending SIGKILL has 2 bad implications:

        - it implies fatal_signal_pending(), so we confuse things
          like wait_for_completion_killable/lock_page_killable.

        - for the sub-namespace inits, the pending SIGKILL can
          mask (legacy_queue) the subsequent SIGKILL from the
          parent namespace which must kill cinit reliably.
          (preparation, cinits don't have SIGNAL_UNKILLABLE yet)

The patch can't help when init is ptraced, but ptracing of init is not
"safe" anyway.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Acked-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Daniel Lezcano <daniel.lezcano@free.fr>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Apr 3, 2009
1 parent 43918f2 commit f008faf
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,21 @@ static int sig_handler_ignored(void __user *handler, int sig)
(handler == SIG_DFL && sig_kernel_ignore(sig));
}

static int sig_ignored(struct task_struct *t, int sig)
static int sig_task_ignored(struct task_struct *t, int sig)
{
void __user *handler;

handler = sig_handler(t, sig);

if (unlikely(t->signal->flags & SIGNAL_UNKILLABLE) &&
handler == SIG_DFL)
return 1;

return sig_handler_ignored(handler, sig);
}

static int sig_ignored(struct task_struct *t, int sig)
{
/*
* Blocked signals are never ignored, since the
* signal handler may change by the time it is
Expand All @@ -67,8 +78,7 @@ static int sig_ignored(struct task_struct *t, int sig)
if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig))
return 0;

handler = sig_handler(t, sig);
if (!sig_handler_ignored(handler, sig))
if (!sig_task_ignored(t, sig))
return 0;

/*
Expand Down

0 comments on commit f008faf

Please sign in to comment.