Skip to content

Commit 2d7f9e2

Browse files
Seth Forsheeebiederm
authored andcommitted
fs: Check for invalid i_uid in may_follow_link()
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 <[email protected]> Acked-by: Serge Hallyn <[email protected]> Signed-off-by: Eric W. Biederman <[email protected]>
1 parent 0d4d717 commit 2d7f9e2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/namei.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ static inline int may_follow_link(struct nameidata *nd)
901901
{
902902
const struct inode *inode;
903903
const struct inode *parent;
904+
kuid_t puid;
904905

905906
if (!sysctl_protected_symlinks)
906907
return 0;
@@ -916,7 +917,8 @@ static inline int may_follow_link(struct nameidata *nd)
916917
return 0;
917918

918919
/* Allowed if parent directory and link owner match. */
919-
if (uid_eq(parent->i_uid, inode->i_uid))
920+
puid = parent->i_uid;
921+
if (uid_valid(puid) && uid_eq(puid, inode->i_uid))
920922
return 0;
921923

922924
if (nd->flags & LOOKUP_RCU)

0 commit comments

Comments
 (0)