diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2014-12-10 21:31:59 -0500 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-12-10 21:31:59 -0500 |
| commit | 707c5960f102f8cdafb9406047b158abc71b391f (patch) | |
| tree | 31d195b1c48cefa2d04da7cc801824f87a0a9887 /ipc | |
| parent | ba00410b8131b23edfb0e09f8b6dd26c8eb621fb (diff) | |
| parent | 3d3d35b1e94ec918fc0ae670663235bf197d8609 (diff) | |
Merge branch 'nsfs' into for-next
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 b54468e48e32..382e2aa42d8a 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 | } |
| @@ -119,7 +120,7 @@ static void free_ipc_ns(struct ipc_namespace *ns) | |||
| 119 | */ | 120 | */ |
| 120 | ipcns_notify(IPCNS_REMOVED); | 121 | ipcns_notify(IPCNS_REMOVED); |
| 121 | put_user_ns(ns->user_ns); | 122 | put_user_ns(ns->user_ns); |
| 122 | proc_free_inum(ns->proc_inum); | 123 | ns_free_inum(&ns->ns); |
| 123 | kfree(ns); | 124 | kfree(ns); |
| 124 | } | 125 | } |
| 125 | 126 | ||
| @@ -149,7 +150,12 @@ void put_ipc_ns(struct ipc_namespace *ns) | |||
| 149 | } | 150 | } |
| 150 | } | 151 | } |
| 151 | 152 | ||
| 152 | static void *ipcns_get(struct task_struct *task) | 153 | static inline struct ipc_namespace *to_ipc_ns(struct ns_common *ns) |
| 154 | { | ||
| 155 | return container_of(ns, struct ipc_namespace, ns); | ||
| 156 | } | ||
| 157 | |||
| 158 | static struct ns_common *ipcns_get(struct task_struct *task) | ||
| 153 | { | 159 | { |
| 154 | struct ipc_namespace *ns = NULL; | 160 | struct ipc_namespace *ns = NULL; |
| 155 | struct nsproxy *nsproxy; | 161 | struct nsproxy *nsproxy; |
| @@ -160,17 +166,17 @@ static void *ipcns_get(struct task_struct *task) | |||
| 160 | ns = get_ipc_ns(nsproxy->ipc_ns); | 166 | ns = get_ipc_ns(nsproxy->ipc_ns); |
| 161 | task_unlock(task); | 167 | task_unlock(task); |
| 162 | 168 | ||
| 163 | return ns; | 169 | return ns ? &ns->ns : NULL; |
| 164 | } | 170 | } |
| 165 | 171 | ||
| 166 | static void ipcns_put(void *ns) | 172 | static void ipcns_put(struct ns_common *ns) |
| 167 | { | 173 | { |
| 168 | return put_ipc_ns(ns); | 174 | return put_ipc_ns(to_ipc_ns(ns)); |
| 169 | } | 175 | } |
| 170 | 176 | ||
| 171 | static int ipcns_install(struct nsproxy *nsproxy, void *new) | 177 | static int ipcns_install(struct nsproxy *nsproxy, struct ns_common *new) |
| 172 | { | 178 | { |
| 173 | struct ipc_namespace *ns = new; | 179 | struct ipc_namespace *ns = to_ipc_ns(new); |
| 174 | if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) || | 180 | if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) || |
| 175 | !ns_capable(current_user_ns(), CAP_SYS_ADMIN)) | 181 | !ns_capable(current_user_ns(), CAP_SYS_ADMIN)) |
| 176 | return -EPERM; | 182 | return -EPERM; |
| @@ -182,18 +188,10 @@ static int ipcns_install(struct nsproxy *nsproxy, void *new) | |||
| 182 | return 0; | 188 | return 0; |
| 183 | } | 189 | } |
| 184 | 190 | ||
| 185 | static unsigned int ipcns_inum(void *vp) | ||
| 186 | { | ||
| 187 | struct ipc_namespace *ns = vp; | ||
| 188 | |||
| 189 | return ns->proc_inum; | ||
| 190 | } | ||
| 191 | |||
| 192 | const struct proc_ns_operations ipcns_operations = { | 191 | const struct proc_ns_operations ipcns_operations = { |
| 193 | .name = "ipc", | 192 | .name = "ipc", |
| 194 | .type = CLONE_NEWIPC, | 193 | .type = CLONE_NEWIPC, |
| 195 | .get = ipcns_get, | 194 | .get = ipcns_get, |
| 196 | .put = ipcns_put, | 195 | .put = ipcns_put, |
| 197 | .install = ipcns_install, | 196 | .install = ipcns_install, |
| 198 | .inum = ipcns_inum, | ||
| 199 | }; | 197 | }; |
