ipc: Initialize ipc_namespace->user_ns early.
authorEric W. Biederman <ebiederm@xmission.com>
Tue, 31 May 2016 17:26:41 +0000 (12:26 -0500)
committerEric W. Biederman <ebiederm@xmission.com>
Thu, 23 Jun 2016 20:41:53 +0000 (15:41 -0500)
Allow the ipc namespace initialization code to depend on ns->user_ns
being set during initialization.

In particular this allows mq_init_ns to use ns->user_ns for permission
checks and initializating s_user_ns while the the mq filesystem is
being mounted.

Acked-by: Seth Forshee <seth.forshee@canonical.com>
Suggested-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
ipc/namespace.c

index 068caf18d56509711e46b47b25a363254d681abe..04cb07eb81f1c148c43915e1eecd57b3cfe9699e 100644 (file)
@@ -34,8 +34,11 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
        ns->ns.ops = &ipcns_operations;
 
        atomic_set(&ns->count, 1);
+       ns->user_ns = get_user_ns(user_ns);
+
        err = mq_init_ns(ns);
        if (err) {
+               put_user_ns(ns->user_ns);
                ns_free_inum(&ns->ns);
                kfree(ns);
                return ERR_PTR(err);
@@ -46,8 +49,6 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
        msg_init_ns(ns);
        shm_init_ns(ns);
 
-       ns->user_ns = get_user_ns(user_ns);
-
        return ns;
 }