]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
fs: Check for invalid i_uid in may_follow_link()
authorSeth Forshee <seth.forshee@canonical.com>
Tue, 26 Apr 2016 19:36:23 +0000 (14:36 -0500)
committerEric W. Biederman <ebiederm@xmission.com>
Thu, 30 Jun 2016 23:05:09 +0000 (18:05 -0500)
Filesystem uids which don't map into a user namespace may result
in inode->i_uid being INVALID_UID. A symlink and its parent
could have different owners in the filesystem can both get
mapped to INVALID_UID, which may result in following a symlink
when this would not have otherwise been permitted when protected
symlinks are enabled.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
fs/namei.c

index 757a32725d92e6556951988d5d33141d305f2016..8701bd9a5270329eeb043c7142f6bc37dd6195dd 100644 (file)
@@ -901,6 +901,7 @@ static inline int may_follow_link(struct nameidata *nd)
 {
        const struct inode *inode;
        const struct inode *parent;
+       kuid_t puid;
 
        if (!sysctl_protected_symlinks)
                return 0;
@@ -916,7 +917,8 @@ static inline int may_follow_link(struct nameidata *nd)
                return 0;
 
        /* Allowed if parent directory and link owner match. */
-       if (uid_eq(parent->i_uid, inode->i_uid))
+       puid = parent->i_uid;
+       if (uid_valid(puid) && uid_eq(puid, inode->i_uid))
                return 0;
 
        if (nd->flags & LOOKUP_RCU)