Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vfs: Fix O_NOFOLLOW behavior for paths with trailing slashes

According to specification

mkdir d; ln -s d a; open("a/", O_NOFOLLOW | O_RDONLY)

should return success but currently it returns ELOOP. This is a
regression caused by path lookup cleanup patch series.

Fix the code to ignore O_NOFOLLOW in case the provided path has trailing
slashes.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Reported-by: Marius Tolzmann <tolzmann@molgen.mpg.de>
Acked-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jan Kara and committed by
Linus Torvalds
002baeec fc8e38f1

+4 -2
+4 -2
fs/namei.c
··· 1641 1641 if (nd->last.name[nd->last.len]) { 1642 1642 if (open_flag & O_CREAT) 1643 1643 goto exit; 1644 - nd->flags |= LOOKUP_DIRECTORY; 1644 + nd->flags |= LOOKUP_DIRECTORY | LOOKUP_FOLLOW; 1645 1645 } 1646 1646 1647 1647 /* just plain open? */ ··· 1830 1830 } 1831 1831 if (open_flag & O_DIRECTORY) 1832 1832 nd.flags |= LOOKUP_DIRECTORY; 1833 + if (!(open_flag & O_NOFOLLOW)) 1834 + nd.flags |= LOOKUP_FOLLOW; 1833 1835 filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname); 1834 1836 while (unlikely(!filp)) { /* trailing symlink */ 1835 1837 struct path holder; ··· 1839 1837 void *cookie; 1840 1838 error = -ELOOP; 1841 1839 /* S_ISDIR part is a temporary automount kludge */ 1842 - if ((open_flag & O_NOFOLLOW) && !S_ISDIR(inode->i_mode)) 1840 + if (!(nd.flags & LOOKUP_FOLLOW) && !S_ISDIR(inode->i_mode)) 1843 1841 goto exit_dput; 1844 1842 if (count++ == 32) 1845 1843 goto exit_dput;