diff mbox

[review,03/13] ipc: Initialize ipc_namespace->user_ns early.

Message ID 20160620172130.15712-3-ebiederm@xmission.com (mailing list archive)
State New, archived
Headers show

Commit Message

Eric W. Biederman June 20, 2016, 5:21 p.m. UTC
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 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Djalal Harouni June 24, 2016, 2:34 p.m. UTC | #1
On Mon, Jun 20, 2016 at 7:21 PM, Eric W. Biederman
<ebiederm@xmission.com> wrote:
> 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>

Reviewed-by: Djalal Harouni <tixxdz@gmail.com>

> ---
>  ipc/namespace.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/ipc/namespace.c b/ipc/namespace.c
> index 068caf18d565..04cb07eb81f1 100644
> --- a/ipc/namespace.c
> +++ b/ipc/namespace.c
> @@ -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;
>  }
>
> --
> 2.8.3
>
diff mbox

Patch

diff --git a/ipc/namespace.c b/ipc/namespace.c
index 068caf18d565..04cb07eb81f1 100644
--- a/ipc/namespace.c
+++ b/ipc/namespace.c
@@ -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;
 }