[CRIU] [PATCH 2/2] restore: remount /proc after clone(CLONE_NEWPID)

Andrew Vagin avagin at parallels.com
Wed Aug 6 11:25:10 PDT 2014


On Wed, Aug 06, 2014 at 01:06:29PM -0500, Tycho Andersen wrote:
> We need to remount /proc after the clone because things like getpid() return
> the pid in the new namespace, but /proc still has the old namespace's info in
> it. This causes problems when e.g. there are some things in criu's private
> mount namespace but not in (the original) init's namespace.

Could you show an example of problems?

> 
> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> ---
>  cr-restore.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/cr-restore.c b/cr-restore.c
> index 88c4b95..6d1c6a2 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -987,6 +987,10 @@ static inline int fork_with_pid(struct pstree_item *item)
>  		goto err_unlock;
>  	}
>  
> +	if (cr.clone_flags & CLONE_NEWPID && mount(NULL, "/proc", "proc", MS_REMOUNT, NULL) < 0) {

We can't remount proc, if we don't create a new mount namespace. But
when we restore a mount namespace, we restore all mounts in it.

> +		pr_perror("can't remount /proc");
> +		goto err_unlock;
> +	}
>  
>  	if (item == root_item)
>  		item->pid.real = ret;
> -- 
> 1.9.1
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list