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

Tycho Andersen tycho.andersen at canonical.com
Wed Aug 6 11:06:29 PDT 2014


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.

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) {
+		pr_perror("can't remount /proc");
+		goto err_unlock;
+	}
 
 	if (item == root_item)
 		item->pid.real = ret;
-- 
1.9.1



More information about the CRIU mailing list