Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932652AbZAQUi7 (ORCPT ); Sat, 17 Jan 2009 15:38:59 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758212AbZAQUit (ORCPT ); Sat, 17 Jan 2009 15:38:49 -0500 Received: from e4.ny.us.ibm.com ([32.97.182.144]:54091 "EHLO e4.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759577AbZAQUis (ORCPT ); Sat, 17 Jan 2009 15:38:48 -0500 Date: Sat, 17 Jan 2009 12:35:32 -0800 From: Sukadev Bhattiprolu To: oleg@redhat.com, ebiederm@xmission.com, roland@redhat.com, bastian@waldi.eu.org Cc: daniel@hozac.com, xemul@openvz.org, containers@lists.osdl.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7][v7] Protect init from unwanted signals more Message-ID: <20090117203532.GC11825@us.ibm.com> References: <20090117202638.GA11825@us.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090117202638.GA11825@us.ibm.com> X-Operating-System: Linux 2.0.32 on an i486 User-Agent: Mutt/1.5.15+20070412 (2007-04-11) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2604 Lines: 79 From: Oleg Nesterov Date: Wed, 24 Dec 2008 13:35:23 -0800 Subject: [PATCH 2/7][v7] 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. Changelog[v5]: - (Oleg Nesterov) Remove SIG_IGN check in sig_task_ignored() and let sig_handler_ignored() check SIG_IGN. Signed-off-by: Sukadev Bhattiprolu Acked-by: Roland McGrath --- kernel/signal.c | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index 7945e71..87f3f30 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -53,10 +53,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 @@ -65,8 +76,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; /* -- 1.5.2.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/