Messages in this thread Patch in this message | | | Date | Tue, 18 Nov 2008 18:59:01 +0100 | From | Oleg Nesterov <> | Subject | [PATCH 1/2] protect /sbin/init from unwanted signals more |
| |
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: Oleg Nesterov <oleg@redhat.com>
--- K-IS/kernel/signal.c~1_INIT_IGN_KILL 2008-11-10 19:21:17.000000000 +0100 +++ K-IS/kernel/signal.c 2008-11-17 19:54:09.000000000 +0100 @@ -43,7 +43,13 @@ static struct kmem_cache *sigqueue_cache static void __user *sig_handler(struct task_struct *t, int sig) { - return t->sighand->action[sig - 1].sa.sa_handler; + void __user *h = t->sighand->action[sig - 1].sa.sa_handler; + + /* drop SIGKILL early to not confuse wait_xxx_killable/etc */ + if (unlikely(t->signal->flags & SIGNAL_UNKILLABLE) && h == SIG_DFL) + h = SIG_IGN; + + return h; } static int sig_handler_ignored(void __user *handler, int sig)
| |