All of lore.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Caj Larsson <caj@omnicloud.com>
Cc: linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Oleg Nesterov <oleg@redhat.com>
Subject: Re: Zombie stuck in zap_pid_ns_processes()
Date: Sun, 24 Mar 2013 04:04:14 -0700	[thread overview]
Message-ID: <87txo1kqj5.fsf@xmission.com> (raw)
In-Reply-To: <CAMoAvfEsvah6VELu9D7k1prB2GLhvyubd35tKgBaJdB=P08+pQ@mail.gmail.com> (Caj Larsson's message of "Wed, 20 Mar 2013 09:43:26 +0100")


Caj Larsson <caj@omnicloud.com> writes:

> Hello,
>
> We are setting up a container using a CLONE_NEWNS linux namespace.
> Previously we used the 3.4.4 kernel, which worked fine. After I
> upgraded i also experienced races in netlink, which has been resolved
> by placing a monitor around the namespace setup. When we upgraded to
> Linux 3.8.0 however our init processes does not get reaped when the
> namespace is killed and lingers as zombie process under the global
> init.
>
> The init has multiple threads when running and two remain in the
> zombie. One of them is hung in zap_pid_ns_processes() and has been set
> uninterruptible. The other one, which has Tgid=PID, is still in
> do_exit().

Doh.

Thank you for the detailed bug report it appears I goofed, and failed
to account for a multi-threaded init.

Will you please verify that the following patch fixes it for you.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index c1c3dc1..72b7722 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -181,6 +181,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
 	int nr;
 	int rc;
 	struct task_struct *task, *me = current;
+	int init_pids = task_pid_vnr(me) == 1 ? 1 : 2;
 
 	/* Don't allow any more processes into the pid namespace */
 	disable_pid_allocation(pid_ns);
@@ -230,7 +231,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
 	 */
 	for (;;) {
 		set_current_state(TASK_UNINTERRUPTIBLE);
-		if (pid_ns->nr_hashed == 1)
+		if (pid_ns->nr_hashed == init_pids)
 			break;
 		schedule();
 	}


  reply	other threads:[~2013-03-24 11:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-20  8:43 Zombie stuck in zap_pid_ns_processes() Caj Larsson
2013-03-24 11:04 ` Eric W. Biederman [this message]
2013-03-24 13:20   ` Oleg Nesterov
2013-03-26 10:29     ` Eric W. Biederman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87txo1kqj5.fsf@xmission.com \
    --to=ebiederm@xmission.com \
    --cc=akpm@linux-foundation.org \
    --cc=caj@omnicloud.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.