aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-07-27 09:21:27 -0400
committerEric W. Biederman <ebiederm@xmission.com>2012-11-20 07:17:40 -0500
commit37657da3c5d4a3bbbbb9d3b78f53a8134a0abae0 (patch)
tree8287f406233004f244d7c0add3d1d7c6fbea4525 /kernel
parent7fa294c8991ce0ed4e713f08209eb2ce3e1044ac (diff)
userns: Allow setting a userns mapping to your current uid.
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/user_namespace.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index 456a6b9fba3..49096d559e0 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -709,6 +709,21 @@ ssize_t proc_projid_map_write(struct file *file, const char __user *buf, size_t
709static bool new_idmap_permitted(struct user_namespace *ns, int cap_setid, 709static bool new_idmap_permitted(struct user_namespace *ns, int cap_setid,
710 struct uid_gid_map *new_map) 710 struct uid_gid_map *new_map)
711{ 711{
712 /* Allow mapping to your own filesystem ids */
713 if ((new_map->nr_extents == 1) && (new_map->extent[0].count == 1)) {
714 u32 id = new_map->extent[0].lower_first;
715 if (cap_setid == CAP_SETUID) {
716 kuid_t uid = make_kuid(ns->parent, id);
717 if (uid_eq(uid, current_fsuid()))
718 return true;
719 }
720 else if (cap_setid == CAP_SETGID) {
721 kgid_t gid = make_kgid(ns->parent, id);
722 if (gid_eq(gid, current_fsgid()))
723 return true;
724 }
725 }
726
712 /* Allow anyone to set a mapping that doesn't require privilege */ 727 /* Allow anyone to set a mapping that doesn't require privilege */
713 if (!cap_valid(cap_setid)) 728 if (!cap_valid(cap_setid))
714 return true; 729 return true;