From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757325AbZBSU0i (ORCPT ); Thu, 19 Feb 2009 15:26:38 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751746AbZBSU0a (ORCPT ); Thu, 19 Feb 2009 15:26:30 -0500 Received: from e38.co.us.ibm.com ([32.97.110.159]:47174 "EHLO e38.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751680AbZBSU03 (ORCPT ); Thu, 19 Feb 2009 15:26:29 -0500 Date: Thu, 19 Feb 2009 12:26:11 -0800 From: Sukadev Bhattiprolu To: Oleg Nesterov Cc: Andrew Morton , roland@redhat.com, "Eric W. Biederman" , daniel@hozac.com, Containers , linux-kernel@vger.kernel.org Subject: Re: [PATCH 5/7][v8] zap_pid_ns_process() should use force_sig() Message-ID: <20090219202611.GA10134@us.ibm.com> References: <20090219030207.GA18783@us.ibm.com> <20090219030704.GE18990@us.ibm.com> <20090219185954.GB374@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090219185954.GB374@redhat.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 Oleg Nesterov [oleg@redhat.com] wrote: | On 02/18, Sukadev Bhattiprolu wrote: | > | > read_lock(&tasklist_lock); | > nr = next_pidmap(pid_ns, 1); | > while (nr > 0) { | > - kill_proc_info(SIGKILL, SEND_SIG_PRIV, nr); | > + rcu_read_lock(); | > + | > + /* | > + * Use force_sig() since it clears SIGNAL_UNKILLABLE ensuring | > + * any nested-container's init processes don't ignore the | > + * signal | > + */ | > + task = pid_task(find_vpid(nr), PIDTYPE_PID); | > + force_sig(SIGKILL, task); | | Shouldn't we check task != NULL ? Yes. Here is the updated patch. --- From: Sukadev Bhattiprolu Date: Wed, 18 Feb 2009 15:12:30 -0800 Subject: [PATCH 5/7][v8] zap_pid_ns_process() should use force_sig() send_signal() assumes that signals with SEND_SIG_PRIV are generated from within the same namespace. So any nested container-init processes become immune to the SIGKILL generated by kill_proc_info() in zap_pid_ns_processes(). Use force_sig() in zap_pid_ns_processes() instead - force_sig() clears the SIGNAL_UNKILLABLE flag ensuring the signal is processed by container-inits. Signed-off-by: Sukadev Bhattiprolu --- kernel/pid_namespace.c | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletions(-) diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c index fab8ea8..2d1001b 100644 --- a/kernel/pid_namespace.c +++ b/kernel/pid_namespace.c @@ -152,6 +152,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns) { int nr; int rc; + struct task_struct *task; /* * The last thread in the cgroup-init thread group is terminating. @@ -169,7 +170,19 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns) read_lock(&tasklist_lock); nr = next_pidmap(pid_ns, 1); while (nr > 0) { - kill_proc_info(SIGKILL, SEND_SIG_PRIV, nr); + rcu_read_lock(); + + /* + * Use force_sig() since it clears SIGNAL_UNKILLABLE ensuring + * any nested-container's init processes don't ignore the + * signal + */ + task = pid_task(find_vpid(nr), PIDTYPE_PID); + if (task) + force_sig(SIGKILL, task); + + rcu_read_unlock(); + nr = next_pidmap(pid_ns, nr); } read_unlock(&tasklist_lock); -- 1.5.2.5