diff options
-rw-r--r-- | include/linux/ipc_namespace.h | 3 | ||||
-rw-r--r-- | ipc/msgutil.c | 1 | ||||
-rw-r--r-- | ipc/namespace.c | 9 | ||||
-rw-r--r-- | kernel/nsproxy.c | 5 |
4 files changed, 16 insertions, 2 deletions
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h index 51952989ad42..d3c32dcec623 100644 --- a/include/linux/ipc_namespace.h +++ b/include/linux/ipc_namespace.h | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | #define IPCNS_CALLBACK_PRI 0 | 16 | #define IPCNS_CALLBACK_PRI 0 |
17 | 17 | ||
18 | struct user_namespace; | ||
18 | 19 | ||
19 | struct ipc_ids { | 20 | struct ipc_ids { |
20 | int in_use; | 21 | int in_use; |
@@ -56,6 +57,8 @@ struct ipc_namespace { | |||
56 | unsigned int mq_msg_max; /* initialized to DFLT_MSGMAX */ | 57 | unsigned int mq_msg_max; /* initialized to DFLT_MSGMAX */ |
57 | unsigned int mq_msgsize_max; /* initialized to DFLT_MSGSIZEMAX */ | 58 | unsigned int mq_msgsize_max; /* initialized to DFLT_MSGSIZEMAX */ |
58 | 59 | ||
60 | /* user_ns which owns the ipc ns */ | ||
61 | struct user_namespace *user_ns; | ||
59 | }; | 62 | }; |
60 | 63 | ||
61 | extern struct ipc_namespace init_ipc_ns; | 64 | extern struct ipc_namespace init_ipc_ns; |
diff --git a/ipc/msgutil.c b/ipc/msgutil.c index f095ee268833..8b5ce5d3f3ef 100644 --- a/ipc/msgutil.c +++ b/ipc/msgutil.c | |||
@@ -32,6 +32,7 @@ struct ipc_namespace init_ipc_ns = { | |||
32 | .mq_msg_max = DFLT_MSGMAX, | 32 | .mq_msg_max = DFLT_MSGMAX, |
33 | .mq_msgsize_max = DFLT_MSGSIZEMAX, | 33 | .mq_msgsize_max = DFLT_MSGSIZEMAX, |
34 | #endif | 34 | #endif |
35 | .user_ns = &init_user_ns, | ||
35 | }; | 36 | }; |
36 | 37 | ||
37 | atomic_t nr_ipc_ns = ATOMIC_INIT(1); | 38 | atomic_t nr_ipc_ns = ATOMIC_INIT(1); |
diff --git a/ipc/namespace.c b/ipc/namespace.c index a1094ff0befa..aa1889962693 100644 --- a/ipc/namespace.c +++ b/ipc/namespace.c | |||
@@ -11,10 +11,11 @@ | |||
11 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
12 | #include <linux/fs.h> | 12 | #include <linux/fs.h> |
13 | #include <linux/mount.h> | 13 | #include <linux/mount.h> |
14 | #include <linux/user_namespace.h> | ||
14 | 15 | ||
15 | #include "util.h" | 16 | #include "util.h" |
16 | 17 | ||
17 | static struct ipc_namespace *create_ipc_ns(void) | 18 | static struct ipc_namespace *create_ipc_ns(struct ipc_namespace *old_ns) |
18 | { | 19 | { |
19 | struct ipc_namespace *ns; | 20 | struct ipc_namespace *ns; |
20 | int err; | 21 | int err; |
@@ -43,6 +44,9 @@ static struct ipc_namespace *create_ipc_ns(void) | |||
43 | ipcns_notify(IPCNS_CREATED); | 44 | ipcns_notify(IPCNS_CREATED); |
44 | register_ipcns_notifier(ns); | 45 | register_ipcns_notifier(ns); |
45 | 46 | ||
47 | ns->user_ns = old_ns->user_ns; | ||
48 | get_user_ns(ns->user_ns); | ||
49 | |||
46 | return ns; | 50 | return ns; |
47 | } | 51 | } |
48 | 52 | ||
@@ -50,7 +54,7 @@ struct ipc_namespace *copy_ipcs(unsigned long flags, struct ipc_namespace *ns) | |||
50 | { | 54 | { |
51 | if (!(flags & CLONE_NEWIPC)) | 55 | if (!(flags & CLONE_NEWIPC)) |
52 | return get_ipc_ns(ns); | 56 | return get_ipc_ns(ns); |
53 | return create_ipc_ns(); | 57 | return create_ipc_ns(ns); |
54 | } | 58 | } |
55 | 59 | ||
56 | /* | 60 | /* |
@@ -105,6 +109,7 @@ static void free_ipc_ns(struct ipc_namespace *ns) | |||
105 | * order to have a correct value when recomputing msgmni. | 109 | * order to have a correct value when recomputing msgmni. |
106 | */ | 110 | */ |
107 | ipcns_notify(IPCNS_REMOVED); | 111 | ipcns_notify(IPCNS_REMOVED); |
112 | put_user_ns(ns->user_ns); | ||
108 | } | 113 | } |
109 | 114 | ||
110 | /* | 115 | /* |
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index b97fc9d04ddf..ac8a56e90bf8 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c | |||
@@ -80,6 +80,11 @@ static struct nsproxy *create_new_namespaces(unsigned long flags, | |||
80 | err = PTR_ERR(new_nsp->ipc_ns); | 80 | err = PTR_ERR(new_nsp->ipc_ns); |
81 | goto out_ipc; | 81 | goto out_ipc; |
82 | } | 82 | } |
83 | if (new_nsp->ipc_ns != tsk->nsproxy->ipc_ns) { | ||
84 | put_user_ns(new_nsp->ipc_ns->user_ns); | ||
85 | new_nsp->ipc_ns->user_ns = task_cred_xxx(tsk, user)->user_ns; | ||
86 | get_user_ns(new_nsp->ipc_ns->user_ns); | ||
87 | } | ||
83 | 88 | ||
84 | new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk)); | 89 | new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk)); |
85 | if (IS_ERR(new_nsp->pid_ns)) { | 90 | if (IS_ERR(new_nsp->pid_ns)) { |