From: Eric W. Biederman Date: Fri, 27 Jul 2012 13:21:27 +0000 (-0700) Subject: userns: Allow setting a userns mapping to your current uid. X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=37657da3c5d4a3bbbbb9d3b78f53a8134a0abae0;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git userns: Allow setting a userns mapping to your current uid. Acked-by: Serge Hallyn Signed-off-by: "Eric W. Biederman" --- diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index 456a6b9fba34..49096d559e08 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 static bool new_idmap_permitted(struct user_namespace *ns, int cap_setid, struct uid_gid_map *new_map) { + /* Allow mapping to your own filesystem ids */ + if ((new_map->nr_extents == 1) && (new_map->extent[0].count == 1)) { + u32 id = new_map->extent[0].lower_first; + if (cap_setid == CAP_SETUID) { + kuid_t uid = make_kuid(ns->parent, id); + if (uid_eq(uid, current_fsuid())) + return true; + } + else if (cap_setid == CAP_SETGID) { + kgid_t gid = make_kgid(ns->parent, id); + if (gid_eq(gid, current_fsgid())) + return true; + } + } + /* Allow anyone to set a mapping that doesn't require privilege */ if (!cap_valid(cap_setid)) return true;