Commit b352659c authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

criu: don't trigger a bug if a task wants to restore a root mntns

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: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent f73802fe
......@@ -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)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment