summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-07-26 10:13:20 +0200
committerEric W. Biederman <ebiederm@xmission.com>2012-11-20 13:17:42 +0100
commit142e1d1d5f088e7a38659daca6e84a730967774a (patch)
treee2297a9a77f55bb15a566979c9c5658cff4737f8 /net
parentuserns: Allow unprivileged users to create new namespaces (diff)
downloadlinux-142e1d1d5f088e7a38659daca6e84a730967774a.tar.xz
linux-142e1d1d5f088e7a38659daca6e84a730967774a.zip
userns: Allow unprivileged use of setns.
- Push the permission check from the core setns syscall into the setns install methods where the user namespace of the target namespace can be determined, and used in a ns_capable call. Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'net')
-rw-r--r--net/core/net_namespace.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 6456439cbbd9..ec2870b44c1f 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -630,8 +630,13 @@ static void netns_put(void *ns)
static int netns_install(struct nsproxy *nsproxy, void *ns)
{
+ struct net *net = ns;
+
+ if (!ns_capable(net->user_ns, CAP_SYS_ADMIN))
+ return -EPERM;
+
put_net(nsproxy->net_ns);
- nsproxy->net_ns = get_net(ns);
+ nsproxy->net_ns = get_net(net);
return 0;
}