@@ -23,6 +23,7 @@ struct mnt_namespace {
u64 event;
unsigned int mounts; /* # of mounts in the namespace */
unsigned int pending_mounts;
+ struct rcu_head rcu;
} __randomize_layout;
struct mnt_pcp {
@@ -3258,7 +3258,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
ns_free_inum(&ns->ns);
dec_mnt_namespaces(ns->ucounts);
put_user_ns(ns->user_ns);
- kfree(ns);
+ kfree_rcu(ns, rcu);
}
/*
@@ -3382,6 +3382,12 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
if (pwdmnt)
mntput(pwdmnt);
+ if (ns_idr_register(&new_ns->ns) < 0) {
+ drop_collected_mounts(&new_ns->root->mnt);
+ free_mnt_ns(new_ns);
+ new_ns = ERR_PTR(-ENOMEM);
+ }
+
return new_ns;
}
@@ -3824,6 +3830,7 @@ static void __init init_mount_tree(void)
list_add(&m->mnt_list, &ns->list);
init_task.nsproxy->mnt_ns = ns;
get_mnt_ns(ns);
+ WARN_ON(ns_idr_register(&ns->ns) < 0);
root.mnt = mnt;
root.dentry = mnt->mnt_root;
@@ -3872,6 +3879,7 @@ void put_mnt_ns(struct mnt_namespace *ns)
{
if (!refcount_dec_and_test(&ns->ns.count))
return;
+ ns_idr_unregister(&ns->ns);
drop_collected_mounts(&ns->root->mnt);
free_mnt_ns(ns);
}
Now they are exposed in /proc/namespace/ directory. Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> --- fs/mount.h | 1 + fs/namespace.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-)