aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/proc/namespaces.c3
-rw-r--r--include/linux/proc_fs.h1
-rw-r--r--ipc/namespace.c37
3 files changed, 41 insertions, 0 deletions
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index b017181f1273..f18d6d58bf79 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -22,6 +22,9 @@ static const struct proc_ns_operations *ns_entries[] = {
22#ifdef CONFIG_UTS_NS 22#ifdef CONFIG_UTS_NS
23 &utsns_operations, 23 &utsns_operations,
24#endif 24#endif
25#ifdef CONFIG_IPC_NS
26 &ipcns_operations,
27#endif
25}; 28};
26 29
27static const struct file_operations ns_file_operations = { 30static const struct file_operations ns_file_operations = {
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 52aa89df8a6d..a23f0b72a023 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -267,6 +267,7 @@ struct proc_ns_operations {
267}; 267};
268extern const struct proc_ns_operations netns_operations; 268extern const struct proc_ns_operations netns_operations;
269extern const struct proc_ns_operations utsns_operations; 269extern const struct proc_ns_operations utsns_operations;
270extern const struct proc_ns_operations ipcns_operations;
270 271
271union proc_op { 272union proc_op {
272 int (*proc_get_link)(struct inode *, struct path *); 273 int (*proc_get_link)(struct inode *, struct path *);
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
145static 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
159static void ipcns_put(void *ns)
160{
161 return put_ipc_ns(ns);
162}
163
164static 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
173const 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};