@@ -63,8 +63,17 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
msg_init_ns(ns);
shm_init_ns(ns);
+ err = ns_idr_register(&ns->ns);
+ if (err)
+ goto fail_exit;
+
return ns;
+fail_exit:
+ mq_put_mnt(ns);
+ sem_exit_ns(ns);
+ msg_exit_ns(ns);
+ shm_exit_ns(ns);
fail_put:
put_user_ns(ns->user_ns);
ns_free_inum(&ns->ns);
@@ -117,6 +126,8 @@ void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids,
static void free_ipc_ns(struct ipc_namespace *ns)
{
+ ns_idr_unregister(&ns->ns);
+
/* mq_put_mnt() waits for a grace period as kern_unmount()
* uses synchronize_rcu().
*/
@@ -128,7 +139,7 @@ static void free_ipc_ns(struct ipc_namespace *ns)
dec_ipc_namespaces(ns->ucounts);
put_user_ns(ns->user_ns);
ns_free_inum(&ns->ns);
- kfree(ns);
+ kfree(ns); /* RCU grace period wait is done in mq_put_mnt */
}
static LLIST_HEAD(free_ipc_list);
@@ -137,6 +137,7 @@ void shm_exit_ns(struct ipc_namespace *ns)
static int __init ipc_ns_init(void)
{
shm_init_ns(&init_ipc_ns);
+ WARN_ON(ns_idr_register(&init_ipc_ns.ns) < 0);
return 0;
}
Now they are exposed in /proc/namespace/ directory. Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> --- ipc/namespace.c | 13 ++++++++++++- ipc/shm.c | 1 + 2 files changed, 13 insertions(+), 1 deletion(-)