diff options
author | Andrey Vagin <avagin@openvz.org> | 2016-09-06 00:47:13 -0700 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2016-09-22 19:59:39 -0500 |
commit | bcac25a58bfc6bd79191ac5d7afb49bea96da8c9 (patch) | |
tree | 28a8ae71b2939267deba0807bcbbed28e77470c0 /kernel/utsname.c | |
parent | 29b4817d4018df78086157ea3a55c1d9424a7cfc (diff) | |
download | linux-bcac25a58bfc6bd79191ac5d7afb49bea96da8c9.tar.gz linux-bcac25a58bfc6bd79191ac5d7afb49bea96da8c9.tar.bz2 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/utsname.c')
-rw-r--r-- | kernel/utsname.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/utsname.c b/kernel/utsname.c index 831ea7108232..e1211a8a5c18 100644 --- a/kernel/utsname.c +++ b/kernel/utsname.c @@ -130,10 +130,16 @@ static int utsns_install(struct nsproxy *nsproxy, struct ns_common *new) return 0; } +static struct user_namespace *utsns_owner(struct ns_common *ns) +{ + return to_uts_ns(ns)->user_ns; +} + const struct proc_ns_operations utsns_operations = { .name = "uts", .type = CLONE_NEWUTS, .get = utsns_get, .put = utsns_put, .install = utsns_install, + .owner = utsns_owner, }; |