aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/namespace.c
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/namespace.c')
-rw-r--r--ipc/namespace.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/ipc/namespace.c b/ipc/namespace.c
index a1094ff0befa..8054c8e5faf1 100644
--- a/ipc/namespace.c
+++ b/ipc/namespace.c
@@ -11,10 +11,12 @@
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
17static struct ipc_namespace *create_ipc_ns(void) 18static struct ipc_namespace *create_ipc_ns(struct task_struct *tsk,
19 struct ipc_namespace *old_ns)
18{ 20{
19 struct ipc_namespace *ns; 21 struct ipc_namespace *ns;
20 int err; 22 int err;
@@ -43,14 +45,19 @@ static struct ipc_namespace *create_ipc_ns(void)
43 ipcns_notify(IPCNS_CREATED); 45 ipcns_notify(IPCNS_CREATED);
44 register_ipcns_notifier(ns); 46 register_ipcns_notifier(ns);
45 47
48 ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
49
46 return ns; 50 return ns;
47} 51}
48 52
49struct ipc_namespace *copy_ipcs(unsigned long flags, struct ipc_namespace *ns) 53struct ipc_namespace *copy_ipcs(unsigned long flags,
54 struct task_struct *tsk)
50{ 55{
56 struct ipc_namespace *ns = tsk->nsproxy->ipc_ns;
57
51 if (!(flags & CLONE_NEWIPC)) 58 if (!(flags & CLONE_NEWIPC))
52 return get_ipc_ns(ns); 59 return get_ipc_ns(ns);
53 return create_ipc_ns(); 60 return create_ipc_ns(tsk, ns);
54} 61}
55 62
56/* 63/*
@@ -97,7 +104,6 @@ static void free_ipc_ns(struct ipc_namespace *ns)
97 sem_exit_ns(ns); 104 sem_exit_ns(ns);
98 msg_exit_ns(ns); 105 msg_exit_ns(ns);
99 shm_exit_ns(ns); 106 shm_exit_ns(ns);
100 kfree(ns);
101 atomic_dec(&nr_ipc_ns); 107 atomic_dec(&nr_ipc_ns);
102 108
103 /* 109 /*
@@ -105,6 +111,8 @@ static void free_ipc_ns(struct ipc_namespace *ns)
105 * order to have a correct value when recomputing msgmni. 111 * order to have a correct value when recomputing msgmni.
106 */ 112 */
107 ipcns_notify(IPCNS_REMOVED); 113 ipcns_notify(IPCNS_REMOVED);
114 put_user_ns(ns->user_ns);
115 kfree(ns);
108} 116}
109 117
110/* 118/*