aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorSerge E. Hallyn <serge@hallyn.com>2011-03-23 19:43:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-23 22:47:07 -0400
commitb515498f5bb5f38fc0e390b4ff7d00b6077de127 (patch)
treeb76dfc56415adee9aec5d8619124059ed3ab02a5 /ipc
parentfc832ad3645f0507f24d11752544525a50a83c71 (diff)
userns: add a user namespace owner of ipc ns
Changelog: Feb 15: Don't set new ipc->user_ns if we didn't create a new ipc_ns. Feb 23: Move extern declaration to ipc_namespace.h, and group fwd declarations at top. Signed-off-by: Serge E. Hallyn <serge.hallyn@canonical.com> Acked-by: "Eric W. Biederman" <ebiederm@xmission.com> Acked-by: Daniel Lezcano <daniel.lezcano@free.fr> Acked-by: David Howells <dhowells@redhat.com> Cc: James Morris <jmorris@namei.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/msgutil.c1
-rw-r--r--ipc/namespace.c9
2 files changed, 8 insertions, 2 deletions
diff --git a/ipc/msgutil.c b/ipc/msgutil.c
index f095ee268833..8b5ce5d3f3ef 100644
--- a/ipc/msgutil.c
+++ b/ipc/msgutil.c
@@ -32,6 +32,7 @@ struct ipc_namespace init_ipc_ns = {
32 .mq_msg_max = DFLT_MSGMAX, 32 .mq_msg_max = DFLT_MSGMAX,
33 .mq_msgsize_max = DFLT_MSGSIZEMAX, 33 .mq_msgsize_max = DFLT_MSGSIZEMAX,
34#endif 34#endif
35 .user_ns = &init_user_ns,
35}; 36};
36 37
37atomic_t nr_ipc_ns = ATOMIC_INIT(1); 38atomic_t nr_ipc_ns = ATOMIC_INIT(1);
diff --git a/ipc/namespace.c b/ipc/namespace.c
index a1094ff0befa..aa1889962693 100644
--- a/ipc/namespace.c
+++ b/ipc/namespace.c
@@ -11,10 +11,11 @@
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 ipc_namespace *old_ns)
18{ 19{
19 struct ipc_namespace *ns; 20 struct ipc_namespace *ns;
20 int err; 21 int err;
@@ -43,6 +44,9 @@ static struct ipc_namespace *create_ipc_ns(void)
43 ipcns_notify(IPCNS_CREATED); 44 ipcns_notify(IPCNS_CREATED);
44 register_ipcns_notifier(ns); 45 register_ipcns_notifier(ns);
45 46
47 ns->user_ns = old_ns->user_ns;
48 get_user_ns(ns->user_ns);
49
46 return ns; 50 return ns;
47} 51}
48 52
@@ -50,7 +54,7 @@ struct ipc_namespace *copy_ipcs(unsigned long flags, struct ipc_namespace *ns)
50{ 54{
51 if (!(flags & CLONE_NEWIPC)) 55 if (!(flags & CLONE_NEWIPC))
52 return get_ipc_ns(ns); 56 return get_ipc_ns(ns);
53 return create_ipc_ns(); 57 return create_ipc_ns(ns);
54} 58}
55 59
56/* 60/*
@@ -105,6 +109,7 @@ static void free_ipc_ns(struct ipc_namespace *ns)
105 * order to have a correct value when recomputing msgmni. 109 * order to have a correct value when recomputing msgmni.
106 */ 110 */
107 ipcns_notify(IPCNS_REMOVED); 111 ipcns_notify(IPCNS_REMOVED);
112 put_user_ns(ns->user_ns);
108} 113}
109 114
110/* 115/*