Commit 386f7fec authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Pavel Emelyanov

mount: Move adding cr-time binfmt_misc to collect_mnt_namespaces()

Binfmt_misc may not exist on NS_ROOT, and exist on NS_OTHER that time.
So, add binfmt_misc only if no one mnt_ns has it.
Signed-off-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 714bd7a0
...@@ -1325,7 +1325,6 @@ static void free_mntinfo(struct mount_info *pms) ...@@ -1325,7 +1325,6 @@ static void free_mntinfo(struct mount_info *pms)
struct mount_info *collect_mntinfo(struct ns_id *ns, bool for_dump) struct mount_info *collect_mntinfo(struct ns_id *ns, bool for_dump)
{ {
struct mount_info *pm; struct mount_info *pm;
int ret;
pm = parse_mountinfo(ns->ns_pid, ns, for_dump); pm = parse_mountinfo(ns->ns_pid, ns, for_dump);
if (!pm) { if (!pm) {
...@@ -1337,22 +1336,6 @@ struct mount_info *collect_mntinfo(struct ns_id *ns, bool for_dump) ...@@ -1337,22 +1336,6 @@ struct mount_info *collect_mntinfo(struct ns_id *ns, bool for_dump)
if (ns->mnt.mntinfo_tree == NULL) if (ns->mnt.mntinfo_tree == NULL)
goto err; goto err;
if (for_dump && ns->type == NS_ROOT && !opts.has_binfmt_misc) {
unsigned int s_dev = 0;
ret = mount_cr_time_mount(ns, &s_dev, "binfmt_misc", BINFMT_MISC_HOME,
"binfmt_misc");
if (ret == -EPERM)
pr_info("Can't mount binfmt_misc: EPERM. Running in user_ns?\n");
else if (ret < 0 && ret != -EBUSY && ret != -ENODEV && ret != -ENOENT) {
pr_err("Can't mount binfmt_misc: %d %s", ret, strerror(-ret));
return NULL;
} else if (ret == 0)
return NULL;
else if (ret > 0 && add_cr_time_mount(ns->mnt.mntinfo_tree, "binfmt_misc",
BINFMT_MISC_HOME, s_dev) < 0)
return NULL;
}
ns->mnt.mntinfo_list = pm; ns->mnt.mntinfo_list = pm;
return pm; return pm;
err: err:
...@@ -3100,6 +3083,34 @@ int collect_mnt_namespaces(bool for_dump) ...@@ -3100,6 +3083,34 @@ int collect_mnt_namespaces(bool for_dump)
if (ret) if (ret)
goto err; goto err;
if (for_dump && !opts.has_binfmt_misc) {
unsigned int s_dev = 0;
struct ns_id *ns;
for (ns = ns_ids; ns != NULL; ns = ns->next) {
if (ns->type == NS_ROOT && ns->nd == &mnt_ns_desc)
break;
}
if (ns) {
ret = mount_cr_time_mount(ns, &s_dev, "binfmt_misc", BINFMT_MISC_HOME,
"binfmt_misc");
if (ret == -EPERM)
pr_info("Can't mount binfmt_misc: EPERM. Running in user_ns?\n");
else if (ret < 0 && ret != -EBUSY && ret != -ENODEV && ret != -ENOENT) {
pr_err("Can't mount binfmt_misc: %d %s", ret, strerror(-ret));
goto err;
} else if (ret == 0) {
ret = -1;
goto err;
} else if (ret > 0 && add_cr_time_mount(ns->mnt.mntinfo_tree, "binfmt_misc",
BINFMT_MISC_HOME, s_dev) < 0) {
ret = -1;
goto err;
}
}
}
ret = resolve_external_mounts(mntinfo); ret = resolve_external_mounts(mntinfo);
if (ret) if (ret)
goto err; goto err;
......
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