diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-07-26 04:13:20 -0400 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-11-20 07:17:42 -0500 |
commit | 142e1d1d5f088e7a38659daca6e84a730967774a (patch) | |
tree | e2297a9a77f55bb15a566979c9c5658cff4737f8 /kernel | |
parent | b33c77ef23dd3ec5692c9c0cc739a3f5f0f2baae (diff) |
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 'kernel')
-rw-r--r-- | kernel/nsproxy.c | 3 | ||||
-rw-r--r-- | kernel/utsname.c | 7 |
2 files changed, 6 insertions, 4 deletions
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 | ||
105 | static int utsns_install(struct nsproxy *nsproxy, void *ns) | 105 | static 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; |