Simplify exec_permission_lite() further
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 28 Aug 2009 17:53:56 +0000 (10:53 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 8 Sep 2009 18:07:43 +0000 (11:07 -0700)
This function is only called for path components that are already known
to be directories (they have a '->lookup' method).  So don't bother
doing that whole S_ISDIR() testing, the whole point of the 'lite()'
version is that we know that we are looking at a directory component,
and that we're only checking name lookup permission.

Reviewed-by: James Morris <jmorris@namei.org>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/namei.c

index 8c3580610eec721d34bccd391d0cdf0f10d28626..929f535fb225944e11f76c0587f58e1c540f5b49 100644 (file)
@@ -445,13 +445,7 @@ static int exec_permission_lite(struct inode *inode)
        if (mode & MAY_EXEC)
                goto ok;
 
-       if ((inode->i_mode & S_IXUGO) && capable(CAP_DAC_OVERRIDE))
-               goto ok;
-
-       if (S_ISDIR(inode->i_mode) && capable(CAP_DAC_OVERRIDE))
-               goto ok;
-
-       if (S_ISDIR(inode->i_mode) && capable(CAP_DAC_READ_SEARCH))
+       if (capable(CAP_DAC_OVERRIDE) || capable(CAP_DAC_READ_SEARCH))
                goto ok;
 
        return -EACCES;