diff options
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/namespace.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ipc/namespace.c b/ipc/namespace.c index 8054c8e5faf1..ce0a647869b1 100644 --- a/ipc/namespace.c +++ b/ipc/namespace.c | |||
@@ -12,6 +12,7 @@ | |||
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 | #include <linux/user_namespace.h> |
15 | #include <linux/proc_fs.h> | ||
15 | 16 | ||
16 | #include "util.h" | 17 | #include "util.h" |
17 | 18 | ||
@@ -140,3 +141,39 @@ void put_ipc_ns(struct ipc_namespace *ns) | |||
140 | free_ipc_ns(ns); | 141 | free_ipc_ns(ns); |
141 | } | 142 | } |
142 | } | 143 | } |
144 | |||
145 | static void *ipcns_get(struct task_struct *task) | ||
146 | { | ||
147 | struct ipc_namespace *ns = NULL; | ||
148 | struct nsproxy *nsproxy; | ||
149 | |||
150 | rcu_read_lock(); | ||
151 | nsproxy = task_nsproxy(task); | ||
152 | if (nsproxy) | ||
153 | ns = get_ipc_ns(nsproxy->ipc_ns); | ||
154 | rcu_read_unlock(); | ||
155 | |||
156 | return ns; | ||
157 | } | ||
158 | |||
159 | static void ipcns_put(void *ns) | ||
160 | { | ||
161 | return put_ipc_ns(ns); | ||
162 | } | ||
163 | |||
164 | static int ipcns_install(struct nsproxy *nsproxy, void *ns) | ||
165 | { | ||
166 | /* Ditch state from the old ipc namespace */ | ||
167 | exit_sem(current); | ||
168 | put_ipc_ns(nsproxy->ipc_ns); | ||
169 | nsproxy->ipc_ns = get_ipc_ns(ns); | ||
170 | return 0; | ||
171 | } | ||
172 | |||
173 | const struct proc_ns_operations ipcns_operations = { | ||
174 | .name = "ipc", | ||
175 | .type = CLONE_NEWIPC, | ||
176 | .get = ipcns_get, | ||
177 | .put = ipcns_put, | ||
178 | .install = ipcns_install, | ||
179 | }; | ||