aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipc/namespace.c6
-rw-r--r--kernel/nsproxy.c3
-rw-r--r--kernel/utsname.c7
-rw-r--r--net/core/net_namespace.c7
4 files changed, 17 insertions, 6 deletions
diff --git a/ipc/namespace.c b/ipc/namespace.c
index f362298c5ce4..6ed33c05cb66 100644
--- a/ipc/namespace.c
+++ b/ipc/namespace.c
@@ -161,8 +161,12 @@ static void ipcns_put(void *ns)
161 return put_ipc_ns(ns); 161 return put_ipc_ns(ns);
162} 162}
163 163
164static int ipcns_install(struct nsproxy *nsproxy, void *ns) 164static int ipcns_install(struct nsproxy *nsproxy, void *new)
165{ 165{
166 struct ipc_namespace *ns = new;
167 if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN))
168 return -EPERM;
169
166 /* Ditch state from the old ipc namespace */ 170 /* Ditch state from the old ipc namespace */
167 exit_sem(current); 171 exit_sem(current);
168 put_ipc_ns(nsproxy->ipc_ns); 172 put_ipc_ns(nsproxy->ipc_ns);
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index a214e0e9035f..4357a0a7d17d 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -242,9 +242,6 @@ SYSCALL_DEFINE2(setns, int, fd, int, nstype)
242 struct file *file; 242 struct file *file;
243 int err; 243 int err;
244 244
245 if (!capable(CAP_SYS_ADMIN))
246 return -EPERM;
247
248 file = proc_ns_fget(fd); 245 file = proc_ns_fget(fd);
249 if (IS_ERR(file)) 246 if (IS_ERR(file))
250 return PTR_ERR(file); 247 return PTR_ERR(file);
diff --git a/kernel/utsname.c b/kernel/utsname.c
index 679d97a5d3fd..4a9362f9325d 100644
--- a/kernel/utsname.c
+++ b/kernel/utsname.c
@@ -102,8 +102,13 @@ static void utsns_put(void *ns)
102 put_uts_ns(ns); 102 put_uts_ns(ns);
103} 103}
104 104
105static int utsns_install(struct nsproxy *nsproxy, void *ns) 105static int utsns_install(struct nsproxy *nsproxy, void *new)
106{ 106{
107 struct uts_namespace *ns = new;
108
109 if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN))
110 return -EPERM;
111
107 get_uts_ns(ns); 112 get_uts_ns(ns);
108 put_uts_ns(nsproxy->uts_ns); 113 put_uts_ns(nsproxy->uts_ns);
109 nsproxy->uts_ns = ns; 114 nsproxy->uts_ns = ns;
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)
630 630
631static int netns_install(struct nsproxy *nsproxy, void *ns) 631static int netns_install(struct nsproxy *nsproxy, void *ns)
632{ 632{
633 struct net *net = ns;
634
635 if (!ns_capable(net->user_ns, CAP_SYS_ADMIN))
636 return -EPERM;
637
633 put_net(nsproxy->net_ns); 638 put_net(nsproxy->net_ns);
634 nsproxy->net_ns = get_net(ns); 639 nsproxy->net_ns = get_net(net);
635 return 0; 640 return 0;
636} 641}
637 642