aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/signal.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2009-04-02 19:58:02 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-02 22:04:58 -0400
commitf008faff0e2777c8b3fe853891b774ca465938d8 (patch)
treed2f325995473a33652f7f7ead71e63d5298fbd01 /kernel/signal.c
parent43918f2bf4806675943416d539d9d5e4d585ebff (diff)
signals: protect init from unwanted signals more
(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>
Diffstat (limited to 'kernel/signal.c')
-rw-r--r--kernel/signal.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/kernel/signal.c b/kernel/signal.c
index 92a1ab004498..8bf7a40e5c71 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -55,10 +55,21 @@ static int sig_handler_ignored(void __user *handler, int sig)
55 (handler == SIG_DFL && sig_kernel_ignore(sig)); 55 (handler == SIG_DFL && sig_kernel_ignore(sig));
56} 56}
57 57
58static int sig_ignored(struct task_struct *t, int sig) 58static int sig_task_ignored(struct task_struct *t, int sig)
59{ 59{
60 void __user *handler; 60 void __user *handler;
61 61
62 handler = sig_handler(t, sig);
63
64 if (unlikely(t->signal->flags & SIGNAL_UNKILLABLE) &&
65 handler == SIG_DFL)
66 return 1;
67
68 return sig_handler_ignored(handler, sig);
69}
70
71static int sig_ignored(struct task_struct *t, int sig)
72{
62 /* 73 /*
63 * Blocked signals are never ignored, since the 74 * Blocked signals are never ignored, since the
64 * signal handler may change by the time it is 75 * signal handler may change by the time it is
@@ -67,8 +78,7 @@ static int sig_ignored(struct task_struct *t, int sig)
67 if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig)) 78 if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig))
68 return 0; 79 return 0;
69 80
70 handler = sig_handler(t, sig); 81 if (!sig_task_ignored(t, sig))
71 if (!sig_handler_ignored(handler, sig))
72 return 0; 82 return 0;
73 83
74 /* 84 /*