[CRIU] [PATCH] criu: don't trigger a bug if a task wants to restore a root mntns
Andrey Vagin
avagin at openvz.org
Fri Nov 27 08:07:04 PST 2015
From: Andrew Vagin <avagin at virtuozzo.com>
It's possiable, if a parent task lives in a sub-mntns and
its child lives in the root mntns. A mount namespace is
restored before forking children, so all children are created
in parent's mount namespace. If a child lives in another
mount namespace, we need to move it into the required mntns.
Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
mount.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/mount.c b/mount.c
index 6ad8058..ca10d43 100644
--- a/mount.c
+++ b/mount.c
@@ -2637,7 +2637,7 @@ int restore_task_mnt_ns(struct pstree_item *current)
return -1;
}
- BUG_ON(nsid->type != NS_OTHER);
+ BUG_ON(nsid->type == NS_CRIU);
if (do_restore_task_mnt_ns(nsid, current))
return -1;
@@ -2656,8 +2656,6 @@ void fini_restore_mntns(void)
for (nsid = ns_ids; nsid != NULL; nsid = nsid->next) {
if (nsid->nd != &mnt_ns_desc)
continue;
- if (root_item->ids->mnt_ns_id == nsid->id)
- continue;
close(nsid->mnt.ns_fd);
}
}
@@ -2856,8 +2854,13 @@ int prepare_mnt_ns(void)
if (nsid->nd != &mnt_ns_desc)
continue;
- if (root_item->ids->mnt_ns_id == nsid->id)
+ if (nsid->type == NS_ROOT) {
+ /* Pin one with a file descriptor */
+ nsid->mnt.ns_fd = open_proc(PROC_SELF, "ns/mnt");
+ if (nsid->mnt.ns_fd < 0)
+ goto err;
continue;
+ }
/* Create the new mount namespace */
if (unshare(CLONE_NEWNS)) {
--
2.4.3
More information about the CRIU
mailing list