kernel: add a helper to get an owning user namespace for a namespace
[cascardo/linux.git] / ipc / namespace.c
index 04cb07e..578d93b 100644 (file)
@@ -43,7 +43,6 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
                kfree(ns);
                return ERR_PTR(err);
        }
-       atomic_inc(&nr_ipc_ns);
 
        sem_init_ns(ns);
        msg_init_ns(ns);
@@ -96,7 +95,6 @@ static void free_ipc_ns(struct ipc_namespace *ns)
        sem_exit_ns(ns);
        msg_exit_ns(ns);
        shm_exit_ns(ns);
-       atomic_dec(&nr_ipc_ns);
 
        put_user_ns(ns->user_ns);
        ns_free_inum(&ns->ns);
@@ -167,10 +165,16 @@ static int ipcns_install(struct nsproxy *nsproxy, struct ns_common *new)
        return 0;
 }
 
+static struct user_namespace *ipcns_owner(struct ns_common *ns)
+{
+       return to_ipc_ns(ns)->user_ns;
+}
+
 const struct proc_ns_operations ipcns_operations = {
        .name           = "ipc",
        .type           = CLONE_NEWIPC,
        .get            = ipcns_get,
        .put            = ipcns_put,
        .install        = ipcns_install,
+       .owner          = ipcns_owner,
 };