diff options
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/msgutil.c | 5 | ||||
-rw-r--r-- | ipc/namespace.c | 32 |
2 files changed, 19 insertions, 18 deletions
diff --git a/ipc/msgutil.c b/ipc/msgutil.c index 7e7095974d54..2b491590ebab 100644 --- a/ipc/msgutil.c +++ b/ipc/msgutil.c | |||
@@ -31,7 +31,10 @@ DEFINE_SPINLOCK(mq_lock); | |||
31 | struct ipc_namespace init_ipc_ns = { | 31 | struct ipc_namespace init_ipc_ns = { |
32 | .count = ATOMIC_INIT(1), | 32 | .count = ATOMIC_INIT(1), |
33 | .user_ns = &init_user_ns, | 33 | .user_ns = &init_user_ns, |
34 | .proc_inum = PROC_IPC_INIT_INO, | 34 | .ns.inum = PROC_IPC_INIT_INO, |
35 | #ifdef CONFIG_IPC_NS | ||
36 | .ns.ops = &ipcns_operations, | ||
37 | #endif | ||
35 | }; | 38 | }; |
36 | 39 | ||
37 | atomic_t nr_ipc_ns = ATOMIC_INIT(1); | 40 | atomic_t nr_ipc_ns = ATOMIC_INIT(1); |
diff --git a/ipc/namespace.c b/ipc/namespace.c index 1a3ffd40356e..068caf18d565 100644 --- a/ipc/namespace.c +++ b/ipc/namespace.c | |||
@@ -26,16 +26,17 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns, | |||
26 | if (ns == NULL) | 26 | if (ns == NULL) |
27 | return ERR_PTR(-ENOMEM); | 27 | return ERR_PTR(-ENOMEM); |
28 | 28 | ||
29 | err = proc_alloc_inum(&ns->proc_inum); | 29 | err = ns_alloc_inum(&ns->ns); |
30 | if (err) { | 30 | if (err) { |
31 | kfree(ns); | 31 | kfree(ns); |
32 | return ERR_PTR(err); | 32 | return ERR_PTR(err); |
33 | } | 33 | } |
34 | ns->ns.ops = &ipcns_operations; | ||
34 | 35 | ||
35 | atomic_set(&ns->count, 1); | 36 | atomic_set(&ns->count, 1); |
36 | err = mq_init_ns(ns); | 37 | err = mq_init_ns(ns); |
37 | if (err) { | 38 | if (err) { |
38 | proc_free_inum(ns->proc_inum); | 39 | ns_free_inum(&ns->ns); |
39 | kfree(ns); | 40 | kfree(ns); |
40 | return ERR_PTR(err); | 41 | return ERR_PTR(err); |
41 | } | 42 | } |
@@ -97,7 +98,7 @@ static void free_ipc_ns(struct ipc_namespace *ns) | |||
97 | atomic_dec(&nr_ipc_ns); | 98 | atomic_dec(&nr_ipc_ns); |
98 | 99 | ||
99 | put_user_ns(ns->user_ns); | 100 | put_user_ns(ns->user_ns); |
100 | proc_free_inum(ns->proc_inum); | 101 | ns_free_inum(&ns->ns); |
101 | kfree(ns); | 102 | kfree(ns); |
102 | } | 103 | } |
103 | 104 | ||
@@ -127,7 +128,12 @@ void put_ipc_ns(struct ipc_namespace *ns) | |||
127 | } | 128 | } |
128 | } | 129 | } |
129 | 130 | ||
130 | static void *ipcns_get(struct task_struct *task) | 131 | static inline struct ipc_namespace *to_ipc_ns(struct ns_common *ns) |
132 | { | ||
133 | return container_of(ns, struct ipc_namespace, ns); | ||
134 | } | ||
135 | |||
136 | static struct ns_common *ipcns_get(struct task_struct *task) | ||
131 | { | 137 | { |
132 | struct ipc_namespace *ns = NULL; | 138 | struct ipc_namespace *ns = NULL; |
133 | struct nsproxy *nsproxy; | 139 | struct nsproxy *nsproxy; |
@@ -138,17 +144,17 @@ static void *ipcns_get(struct task_struct *task) | |||
138 | ns = get_ipc_ns(nsproxy->ipc_ns); | 144 | ns = get_ipc_ns(nsproxy->ipc_ns); |
139 | task_unlock(task); | 145 | task_unlock(task); |
140 | 146 | ||
141 | return ns; | 147 | return ns ? &ns->ns : NULL; |
142 | } | 148 | } |
143 | 149 | ||
144 | static void ipcns_put(void *ns) | 150 | static void ipcns_put(struct ns_common *ns) |
145 | { | 151 | { |
146 | return put_ipc_ns(ns); | 152 | return put_ipc_ns(to_ipc_ns(ns)); |
147 | } | 153 | } |
148 | 154 | ||
149 | static int ipcns_install(struct nsproxy *nsproxy, void *new) | 155 | static int ipcns_install(struct nsproxy *nsproxy, struct ns_common *new) |
150 | { | 156 | { |
151 | struct ipc_namespace *ns = new; | 157 | struct ipc_namespace *ns = to_ipc_ns(new); |
152 | if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) || | 158 | if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) || |
153 | !ns_capable(current_user_ns(), CAP_SYS_ADMIN)) | 159 | !ns_capable(current_user_ns(), CAP_SYS_ADMIN)) |
154 | return -EPERM; | 160 | return -EPERM; |
@@ -160,18 +166,10 @@ static int ipcns_install(struct nsproxy *nsproxy, void *new) | |||
160 | return 0; | 166 | return 0; |
161 | } | 167 | } |
162 | 168 | ||
163 | static unsigned int ipcns_inum(void *vp) | ||
164 | { | ||
165 | struct ipc_namespace *ns = vp; | ||
166 | |||
167 | return ns->proc_inum; | ||
168 | } | ||
169 | |||
170 | const struct proc_ns_operations ipcns_operations = { | 169 | const struct proc_ns_operations ipcns_operations = { |
171 | .name = "ipc", | 170 | .name = "ipc", |
172 | .type = CLONE_NEWIPC, | 171 | .type = CLONE_NEWIPC, |
173 | .get = ipcns_get, | 172 | .get = ipcns_get, |
174 | .put = ipcns_put, | 173 | .put = ipcns_put, |
175 | .install = ipcns_install, | 174 | .install = ipcns_install, |
176 | .inum = ipcns_inum, | ||
177 | }; | 175 | }; |