[CRIU] [PATCH 2/2] criu: don't trigger a bug if a task wants to restore a root mntns
Pavel Emelyanov
xemul at parallels.com
Fri Nov 27 05:17:20 PST 2015
On 11/27/2015 04:00 PM, Andrey Vagin wrote:
> 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..afb5986 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;
How about skipping NS_CRIU namespace? Is it on the list?
> 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 (root_item->ids->mnt_ns_id == nsid->id) {
Maybe fix this check to be 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)) {
>
More information about the CRIU
mailing list