Linux Container Development
 help / color / mirror / Atom feed
From: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
To: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: [PATCH] c/r: restart to handle checkpoint images lacking {uts, ipc}-ns
Date: Thu, 11 Feb 2010 13:47:31 -0500	[thread overview]
Message-ID: <4B7450C3.7050104@cs.columbia.edu> (raw)
In-Reply-To: <1265913760-26854-1-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>


An innocent ctrl-t misspelled Dan's email :(
Resending with the proper address.

Oren.

Oren Laadan wrote:
> A checkpoint taken on a kernel without CONFIG_{IPC,UTS}_NS will leave
> the corresponding objref field in the nsproxy header untouched, and
> therefore it will remain zero.
> 
> This patch ensures that do_restore_ns() gracefully handles this by
> borrowing from the nsproxy of the root-task.
> 
> Signed-off-by: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
> ---
>  kernel/nsproxy.c |   71 +++++++++++++++++++++++++++++------------------------
>  1 files changed, 39 insertions(+), 32 deletions(-)
> 
> diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
> index b0e71f2..cfef7bc 100644
> --- a/kernel/nsproxy.c
> +++ b/kernel/nsproxy.c
> @@ -312,54 +312,61 @@ static struct nsproxy *do_restore_ns(struct ckpt_ctx *ctx)
>  	struct nsproxy *nsproxy = NULL;
>  	struct uts_namespace *uts_ns;
>  	struct ipc_namespace *ipc_ns;
> +	struct mnt_namespace *mnt_ns;
> +	struct net *net_ns;
>  	int ret;
>  
>  	h = ckpt_read_obj_type(ctx, sizeof(*h), CKPT_HDR_NS);
>  	if (IS_ERR(h))
>  		return (struct nsproxy *) h;
>  
> -	ret = -EINVAL;
> -	if (h->uts_objref <= 0 ||
> -	    h->ipc_objref <= 0)
> -		goto out;
> -
> -	uts_ns = ckpt_obj_fetch(ctx, h->uts_objref, CKPT_OBJ_UTS_NS);
> +	if (h->uts_objref == 0)
> +		uts_ns = ctx->root_nsproxy->uts_ns;
> +	else
> +		uts_ns = ckpt_obj_fetch(ctx, h->uts_objref, CKPT_OBJ_UTS_NS);
>  	if (IS_ERR(uts_ns)) {
>  		ret = PTR_ERR(uts_ns);
>  		goto out;
>  	}
> -	ipc_ns = ckpt_obj_fetch(ctx, h->ipc_objref, CKPT_OBJ_IPC_NS);
> +
> +	if (h->ipc_objref == 0)
> +		ipc_ns = ctx->root_nsproxy->ipc_ns;
> +	else
> +		ipc_ns = ckpt_obj_fetch(ctx, h->ipc_objref, CKPT_OBJ_IPC_NS);
>  	if (IS_ERR(ipc_ns)) {
>  		ret = PTR_ERR(ipc_ns);
>  		goto out;
>  	}
>  
> -#if defined(COFNIG_UTS_NS) || defined(CONFIG_IPC_NS)
> -	ret = -ENOMEM;
> -	nsproxy = create_nsproxy();
> -	if (!nsproxy)
> -		goto out;
> +	mnt_ns = ctx->root_nsproxy->mnt_ns;
> +	net_ns = ctx->root_nsproxy->net_ns;
> +
> +	if (uts_ns == current->nsproxy->uts_ns &&
> +	    ipc_ns == current->nsproxy->ipc_ns &&
> +	    mnt_ns == current->nsproxy->mnt_ns &&
> +	    net_ns == current->nsproxy->net_ns) {
> +		/* all xxx-ns are identical: reuse nsproxy */
> +		nsproxy = current->nsproxy;
> +		get_nsproxy(nsproxy);
> +	} else {
> +		ret = -ENOMEM;
> +		nsproxy = create_nsproxy();
> +		if (!nsproxy)
> +			goto out;
> +
> +		get_uts_ns(uts_ns);
> +		nsproxy->uts_ns = uts_ns;
> +		get_ipc_ns(ipc_ns);
> +		nsproxy->ipc_ns = ipc_ns;
> +		get_mnt_ns(mnt_ns);
> +		nsproxy->mnt_ns = mnt_ns;
> +		get_net(net_ns);
> +		nsproxy->net_ns = net_ns;
> +
> +		get_pid_ns(current->nsproxy->pid_ns);
> +		nsproxy->pid_ns = current->nsproxy->pid_ns;
> +	}
>  
> -	get_uts_ns(uts_ns);
> -	nsproxy->uts_ns = uts_ns;
> -	get_ipc_ns(ipc_ns);
> -	nsproxy->ipc_ns = ipc_ns;
> -
> -	get_pid_ns(current->nsproxy->pid_ns);
> -	nsproxy->pid_ns = current->nsproxy->pid_ns;
> -	get_mnt_ns(current->nsproxy->mnt_ns);
> -	nsproxy->mnt_ns = current->nsproxy->mnt_ns;
> -	get_net(current->nsproxy->net_ns);
> -	nsproxy->net_ns = current->nsproxy->net_ns;
> -#else
> -	nsproxy = current->nsproxy;
> -	get_nsproxy(nsproxy);
> -
> -	BUG_ON(nsproxy->uts_ns != uts_ns);
> -	BUG_ON(nsproxy->ipc_ns != ipc_ns);
> -#endif
> -
> -	/* TODO: add more namespaces here */
>  	ret = 0;
>   out:
>  	if (ret < 0)

  parent reply	other threads:[~2010-02-11 18:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-11 18:42 [PATCH] c/r: restart to handle checkpoint images lacking {uts, ipc}-ns Oren Laadan
     [not found] ` <1265913760-26854-1-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2010-02-11 18:47   ` Oren Laadan [this message]
2010-02-11 21:14   ` Dan Smith

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=4B7450C3.7050104@cs.columbia.edu \
    --to=orenl-eqauephvms7envbuuze7ea@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=danms-r/Jw6+rmf7HQT0dZR+AlfA@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