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

Tycho Andersen tycho.andersen at canonical.com
Thu Aug 7 06:46:19 PDT 2014


On Thu, Aug 07, 2014 at 10:08:06AM +0400, Pavel Emelyanov wrote:
> On 08/07/2014 07:33 AM, Tycho Andersen wrote:
> > Isn't it still a bug not to re-mount /proc though?
> 
> If we don't create new mount namespace, then re-mounting seem like bug --
> if we change the way information is represented in it for root (init) task
> we restore, then we change the way it looks for the tasks living in the
> pid namespace criu was launched in.

Yep, agreed.

> > Or, I guess it
> > isn't totally a bug, as long as you don't look in /proc, but criu
> > seems to do that a lot. 
> 
> It does, but it should do all the proc stuff via proc service descriptor.
> The open_proc, fopen_proc and others do exactly this.
> 
> Do you know any places where criu just goes and accesses "/proc/..."?

Ah, I didn't realize those would poke at the right /proc, that is
handy :). Yes, parse_mountinfo looks in /proc directly. However, when I do
this:

diff --git a/proc_parse.c b/proc_parse.c
index 3da5445..68d932b 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -944,8 +944,7 @@ struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid)
        FILE *f;
        char str[1024];
 
-       snprintf(str, sizeof(str), "/proc/%d/mountinfo", pid);
-       f = fopen(str, "r");
+       f = fopen_proc(pid, "mountinfo");
        if (!f) {
                pr_perror("Can't open %d mountinfo", pid);
                return NULL;

I still get Error (mount.c:1952): New root and old root are the same.

Tycho


More information about the CRIU mailing list