All of lore.kernel.org
 help / color / mirror / Atom feed
From: sukadev@us.ibm.com
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Pavel Emelyanov <xemul@openvz.org>,
	Robert Rex <robert.rex@exasol.com>,
	Roland McGrath <roland@redhat.com>,
	Serge Hallyn <serue@us.ibm.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] pid_ns: zap_pid_ns_processes: fix the ->child_reaper changing
Date: Tue, 26 Aug 2008 18:43:49 -0700	[thread overview]
Message-ID: <20080827014348.GA23474@us.ibm.com> (raw)
In-Reply-To: <20080824154911.GA3777@tv-sign.ru>

Oleg Nesterov [oleg@tv-sign.ru] wrote:
| zap_pid_ns_processes() sets pid_ns->child_reaper = NULL, this is wrong.
| 
| Yes, we have already killed all tasks in this namespace, and sys_wait4()
| doesn't see any child. But this doesn't mean ->children list is empty,
| we may have EXIT_DEAD tasks which are not visible to do_wait(). In that
| case the subsequent forget_original_parent() will crash the kernel because
| it will try to re-parent these tasks to the NULL reaper.
| 
| Even if there are no childs, it is not good that forget_original_parent()
| uses reaper == NULL.
| 
| Change the code to set ->child_reaper = init_pid_ns.child_reaper instead.
| We could use pid_ns->parent->child_reaper as well, I think this does not
| really matter. These EXIT_DEAD tasks are not visible to the new ->parent
| after re-parenting, they will silently do release_task() eventually.
| 
| Note that we must change ->child_reaper, otherwise forget_original_parent()
| will use reaper == father, and in that case we will hit the (correct)
| BUG_ON(!list_empty(&father->children)).
| 
| Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

Acked-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>

| 
| --- 2.6.27-rc4/kernel/pid_namespace.c~1_ZAP_DONT_CLEAR_REAPER	2008-07-30 13:12:49.000000000 +0400
| +++ 2.6.27-rc4/kernel/pid_namespace.c	2008-08-24 17:22:59.000000000 +0400
| @@ -179,9 +179,12 @@ void zap_pid_ns_processes(struct pid_nam
|  		rc = sys_wait4(-1, NULL, __WALL, NULL);
|  	} while (rc != -ECHILD);
| 
| -
| -	/* Child reaper for the pid namespace is going away */
| -	pid_ns->child_reaper = NULL;
| +	/*
| +	 * We can not clear ->child_reaper or leave it alone.
| +	 * There may by stealth EXIT_DEAD tasks on ->children,
| +	 * forget_original_parent() must move them somewhere.
| +	 */
| +	pid_ns->child_reaper = init_pid_ns.child_reaper;
|  	acct_exit_ns(pid_ns);
|  	return;
|  }
| 
| --
| 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/

  parent reply	other threads:[~2008-08-27  1:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-24 15:49 [PATCH 1/4] pid_ns: zap_pid_ns_processes: fix the ->child_reaper changing Oleg Nesterov
2008-08-26 21:25 ` Serge E. Hallyn
2008-08-27 16:36   ` Oleg Nesterov
2008-08-27  1:43 ` sukadev [this message]
2008-08-27 11:35 ` Pavel Emelyanov

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=20080827014348.GA23474@us.ibm.com \
    --to=sukadev@us.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@tv-sign.ru \
    --cc=robert.rex@exasol.com \
    --cc=roland@redhat.com \
    --cc=serue@us.ibm.com \
    --cc=xemul@openvz.org \
    /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.