diff options
author | Andrey Vagin <avagin@openvz.org> | 2016-09-06 09:47:13 +0200 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2016-09-23 02:59:39 +0200 |
commit | bcac25a58bfc6bd79191ac5d7afb49bea96da8c9 (patch) | |
tree | 28a8ae71b2939267deba0807bcbbed28e77470c0 /kernel/pid_namespace.c | |
parent | Linux 4.8-rc1 (diff) | |
download | linux-bcac25a58bfc6bd79191ac5d7afb49bea96da8c9.tar.xz linux-bcac25a58bfc6bd79191ac5d7afb49bea96da8c9.zip |
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 'kernel/pid_namespace.c')
-rw-r--r-- | kernel/pid_namespace.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c index a65ba137fd15..c02d744225e1 100644 --- a/kernel/pid_namespace.c +++ b/kernel/pid_namespace.c @@ -388,12 +388,18 @@ static int pidns_install(struct nsproxy *nsproxy, struct ns_common *ns) return 0; } +static struct user_namespace *pidns_owner(struct ns_common *ns) +{ + return to_pid_ns(ns)->user_ns; +} + const struct proc_ns_operations pidns_operations = { .name = "pid", .type = CLONE_NEWPID, .get = pidns_get, .put = pidns_put, .install = pidns_install, + .owner = pidns_owner, }; static __init int pid_namespaces_init(void) |