summaryrefslogtreecommitdiffstats
path: root/kernel/capability.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-03-12 21:08:45 +0100
committerEric W. Biederman <ebiederm@xmission.com>2012-05-15 23:59:24 +0200
commit65cc5a17ad3388f89ddc3d68226a09242656809b (patch)
tree04db523bba313b28d00ff2a1864a4d4dde40c97e /kernel/capability.c
parentuserns: Fail exec for suid and sgid binaries with ids outside our user namesp... (diff)
downloadlinux-65cc5a17ad3388f89ddc3d68226a09242656809b.tar.xz
linux-65cc5a17ad3388f89ddc3d68226a09242656809b.zip
userns: Teach inode_capable to understand inodes whose uids map to other namespaces.
Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'kernel/capability.c')
-rw-r--r--kernel/capability.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/kernel/capability.c b/kernel/capability.c
index cc5f0718215d..493d97259484 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -429,12 +429,14 @@ bool nsown_capable(int cap)
* targeted at it's own user namespace and that the given inode is owned
* by the current user namespace or a child namespace.
*
- * Currently inodes can only be owned by the initial user namespace.
+ * Currently we check to see if an inode is owned by the current
+ * user namespace by seeing if the inode's owner maps into the
+ * current user namespace.
*
*/
bool inode_capable(const struct inode *inode, int cap)
{
struct user_namespace *ns = current_user_ns();
- return ns_capable(ns, cap) && (ns == &init_user_ns);
+ return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
}