path_init(): don't bother with checking MAY_EXEC for LOOKUP_ROOT
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 15 Apr 2017 21:29:14 +0000 (17:29 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 21 Apr 2017 18:05:35 +0000 (14:05 -0400)
we'll hit that check in link_path_walk() anyway.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namei.c

index 19dcf62133cc95162d364f7ef43c17d280ee6448..60c0a78ebca7a253d3a33e249f31539f2c5edb64 100644 (file)
@@ -2142,7 +2142,6 @@ OK:
 
 static const char *path_init(struct nameidata *nd, unsigned flags)
 {
-       int retval = 0;
        const char *s = nd->name->name;
 
        if (!*s)
@@ -2154,13 +2153,8 @@ static const char *path_init(struct nameidata *nd, unsigned flags)
        if (flags & LOOKUP_ROOT) {
                struct dentry *root = nd->root.dentry;
                struct inode *inode = root->d_inode;
-               if (*s) {
-                       if (!d_can_lookup(root))
-                               return ERR_PTR(-ENOTDIR);
-                       retval = inode_permission(inode, MAY_EXEC);
-                       if (retval)
-                               return ERR_PTR(retval);
-               }
+               if (*s && unlikely(!d_can_lookup(root)))
+                       return ERR_PTR(-ENOTDIR);
                nd->path = nd->root;
                nd->inode = inode;
                if (flags & LOOKUP_RCU) {