Linux Container Development
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
Cc: Linux Containers <containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>
Subject: [PATCH linux-cr] nsproxy: record ambient namespaces
Date: Thu, 25 Feb 2010 16:56:41 -0600	[thread overview]
Message-ID: <20100225225641.GA9386@us.ibm.com> (raw)

The nsproxy restore path recognizes that an objref of 0 for
ipc or uts ns means don't unshare it.  But the checkpoint side
forgot to write down 0 when the ipc or uts ns isn't unshared!

Fix that.

To test, run a program with a private pidns but shared utsns
which does

	sleep(5);
	sethostname("serge", 6);

checkpoint it, reset your hostname (if you let the program
complete), then restart the program: without this patch, it
will not reset your hostname.  It should, and with this patch
it will.

Signed-off-by: Serge E. Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 kernel/nsproxy.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index 0da0d83..dcb502c 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -280,13 +280,20 @@ static int do_checkpoint_ns(struct ckpt_ctx *ctx, struct nsproxy *nsproxy)
 	if (!h)
 		return -ENOMEM;
 
-	ret = checkpoint_obj(ctx, nsproxy->uts_ns, CKPT_OBJ_UTS_NS);
-	if (ret <= 0)
-		goto out;
+	ret = 0;
+	if (nsproxy->uts_ns != ctx->root_nsproxy->uts_ns) {
+		ret = checkpoint_obj(ctx, nsproxy->uts_ns, CKPT_OBJ_UTS_NS);
+		if (ret <= 0)
+			goto out;
+	}
 	h->uts_objref = ret;
-	ret = checkpoint_obj(ctx, nsproxy->ipc_ns, CKPT_OBJ_IPC_NS);
-	if (ret < 0)
-		goto out;
+
+	ret = 0;
+	if (nsproxy->ipc_ns != ctx->root_nsproxy->ipc_ns) {
+		ret = checkpoint_obj(ctx, nsproxy->ipc_ns, CKPT_OBJ_IPC_NS);
+		if (ret < 0)
+			goto out;
+	}
 	h->ipc_objref = ret;
 
 	/* FIXME: for now, only marked visited to pacify leaks */
-- 
1.6.1

             reply	other threads:[~2010-02-25 22:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-25 22:56 Serge E. Hallyn [this message]
     [not found] ` <20100225225641.GA9386-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-01 19:20   ` [PATCH linux-cr] nsproxy: record ambient namespaces Oren Laadan
     [not found]     ` <4B8C136E.5060704-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2010-03-02 18:42       ` Serge E. Hallyn
     [not found]         ` <20100302184253.GA18840-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-02 21:20           ` Oren Laadan
     [not found]             ` <4B8D8102.9020500-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2010-03-02 21:25               ` Serge E. Hallyn

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=20100225225641.GA9386@us.ibm.com \
    --to=serue-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
    --cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
    --cc=orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox