aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorAndrey Vagin <avagin@openvz.org>2016-09-06 03:47:13 -0400
committerEric W. Biederman <ebiederm@xmission.com>2016-09-22 20:59:39 -0400
commitbcac25a58bfc6bd79191ac5d7afb49bea96da8c9 (patch)
tree28a8ae71b2939267deba0807bcbbed28e77470c0 /ipc
parent29b4817d4018df78086157ea3a55c1d9424a7cfc (diff)
kernel: add a helper to get an owning user namespace for a namespace
Return -EPERM if an owning user namespace is outside of a process current user namespace. v2: In a first version ns_get_owner returned ENOENT for init_user_ns. This special cases was removed from this version. There is nothing outside of init_user_ns, so we can return EPERM. v3: rename ns->get_owner() to ns->owner(). get_* usually means that it grabs a reference. Acked-by: Serge Hallyn <serge@hallyn.com> Signed-off-by: Andrei Vagin <avagin@openvz.org> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/namespace.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ipc/namespace.c b/ipc/namespace.c
index d87e6baa1323..578d93be619d 100644
--- a/ipc/namespace.c
+++ b/ipc/namespace.c
@@ -165,10 +165,16 @@ static int ipcns_install(struct nsproxy *nsproxy, struct ns_common *new)
165 return 0; 165 return 0;
166} 166}
167 167
168static struct user_namespace *ipcns_owner(struct ns_common *ns)
169{
170 return to_ipc_ns(ns)->user_ns;
171}
172
168const struct proc_ns_operations ipcns_operations = { 173const struct proc_ns_operations ipcns_operations = {
169 .name = "ipc", 174 .name = "ipc",
170 .type = CLONE_NEWIPC, 175 .type = CLONE_NEWIPC,
171 .get = ipcns_get, 176 .get = ipcns_get,
172 .put = ipcns_put, 177 .put = ipcns_put,
173 .install = ipcns_install, 178 .install = ipcns_install,
179 .owner = ipcns_owner,
174}; 180};