aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-12-11 08:56:16 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2012-12-20 13:57:04 -0500
commit582aa64a04a579d47d05e4a0ee85bf047978ef4d (patch)
tree96c742c282b0ee6787d99704687326084a744487 /fs/namei.c
parent1e75529e3c6c18dc535f38454173c4f2dfa99685 (diff)
vfs: remove unneeded permission check from path_init
When path_init is called with a valid dfd, that code checks permissions on the open directory fd and returns an error if the check fails. This permission check is redundant, however. Both callers of path_init immediately call link_path_walk afterward. The first thing that link_path_walk does for pathnames that do not consist only of slashes is to check for exec permissions at the starting point of the path walk. And this check in path_init() is on the path taken only when *name != '/' && *name != '\0'. In most cases, these checks are very quick, but when the dfd is for a file on a NFS mount with the actimeo=0, each permission check goes out onto the wire. The result is 2 identical ACCESS calls. Given that these codepaths are fairly "hot", I think it makes sense to eliminate the permission check in path_init and simply assume that the caller will eventually check the permissions before proceeding. Reported-by: Dave Wysochanski <dwysocha@redhat.com> Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 5f4cdf3ad913..e245d88b4d69 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1903,6 +1903,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
1903 get_fs_pwd(current->fs, &nd->path); 1903 get_fs_pwd(current->fs, &nd->path);
1904 } 1904 }
1905 } else { 1905 } else {
1906 /* Caller must check execute permissions on the starting path component */
1906 struct fd f = fdget_raw(dfd); 1907 struct fd f = fdget_raw(dfd);
1907 struct dentry *dentry; 1908 struct dentry *dentry;
1908 1909
@@ -1916,12 +1917,6 @@ static int path_init(int dfd, const char *name, unsigned int flags,
1916 fdput(f); 1917 fdput(f);
1917 return -ENOTDIR; 1918 return -ENOTDIR;
1918 } 1919 }
1919
1920 retval = inode_permission(dentry->d_inode, MAY_EXEC);
1921 if (retval) {
1922 fdput(f);
1923 return retval;
1924 }
1925 } 1920 }
1926 1921
1927 nd->path = f.file->f_path; 1922 nd->path = f.file->f_path;