Simplify exec_permission_lite(), part 3
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 28 Aug 2009 18:08:31 +0000 (11:08 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 8 Sep 2009 18:07:44 +0000 (11:07 -0700)
Don't call down to the generic inode_permission() function just to
call the inode-specific permission function - just do it directly.

The generic inode_permission() code does things like checking MAY_WRITE
and devcgroup_inode_permission(), neither of which are relevant for the
light pathname walk permission checks (we always do just MAY_EXEC, and
the inode is never a special device).

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 929f535fb225944e11f76c0587f58e1c540f5b49..e645e307036057e678d0d245bccf8e2d653cbf9a 100644 (file)
@@ -434,8 +434,12 @@ static int exec_permission_lite(struct inode *inode)
 {
        umode_t mode = inode->i_mode;
 
-       if (inode->i_op->permission)
-               return inode_permission(inode, MAY_EXEC);
+       if (inode->i_op->permission) {
+               int ret = inode->i_op->permission(inode, MAY_EXEC);
+               if (!ret)
+                       goto ok;
+               return ret;
+       }
 
        if (current_fsuid() == inode->i_uid)
                mode >>= 6;