]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] permission checks for chdir need special treatment only on the last step
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 16 Jul 2008 13:51:03 +0000 (09:51 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 27 Jul 2008 00:53:19 +0000 (20:53 -0400)
... so we ought to pass MAY_CHDIR to vfs_permission() instead of having
it triggered on every step of preceding pathname resolution.  LOOKUP_CHDIR
is killed by that.

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

index ae0e56fdb7429cf363f0ad8d60b91591434d8fbb..6c76e1ee9c4584fdc019882bd2849c00180a05e2 100644 (file)
@@ -268,8 +268,6 @@ int permission(struct inode *inode, int mask, struct nameidata *nd)
                if (nd) {
                        if (nd->flags & LOOKUP_ACCESS)
                                extra |= MAY_ACCESS;
-                       if (nd->flags & LOOKUP_CHDIR)
-                               extra |= MAY_CHDIR;
                        if (nd->flags & LOOKUP_OPEN)
                                extra |= MAY_OPEN;
                }
index b2e4c93aed03ab4d548552588edd9aca664e0880..8e02d42bfe443d37159750abef24fa0140db2411 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -501,12 +501,11 @@ asmlinkage long sys_chdir(const char __user * filename)
        struct nameidata nd;
        int error;
 
-       error = __user_walk(filename,
-                           LOOKUP_FOLLOW|LOOKUP_DIRECTORY|LOOKUP_CHDIR, &nd);
+       error = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
        if (error)
                goto out;
 
-       error = vfs_permission(&nd, MAY_EXEC);
+       error = vfs_permission(&nd, MAY_EXEC | MAY_CHDIR);
        if (error)
                goto dput_and_out;
 
index 24d88e98a62648180a553fdfb457837bcbcb5c00..3cf62d26d49327ad0581ea99a3b3d098b70d939f 100644 (file)
@@ -55,7 +55,6 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
 #define LOOKUP_OPEN            (0x0100)
 #define LOOKUP_CREATE          (0x0200)
 #define LOOKUP_ACCESS          (0x0400)
-#define LOOKUP_CHDIR           (0x0800)
 
 extern int __user_walk(const char __user *, unsigned, struct nameidata *);
 extern int __user_walk_fd(int dfd, const char __user *, unsigned, struct nameidata *);