[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git-commits-head
Subject:    vfs: move MAY_EXEC check from __lookup_hash()
From:       "Linux Kernel Mailing List" <linux-kernel () vger ! kernel ! org>
Date:       2012-03-31 21:21:05
Message-ID: 20120331212105.C8DA17C00D7 () ra ! kernel ! org
[Download RAW message or body]

Gitweb:     http://git.kernel.org/linus/;a=commit;h=cda309de253f338b04d15b4478e45fc3a0fcc7a3
Commit:     cda309de253f338b04d15b4478e45fc3a0fcc7a3
Parent:     3637c05d881b2b7bab36f339245b8963f5b29c9f
Author:     Miklos Szeredi <mszeredi@suse.cz>
AuthorDate: Mon Mar 26 12:54:21 2012 +0200
Committer:  Al Viro <viro@zeniv.linux.org.uk>
CommitDate: Sat Mar 31 16:03:16 2012 -0400

    vfs: move MAY_EXEC check from __lookup_hash()
    
    The only caller of __lookup_hash() that needs the exec permission check on
    parent is lookup_one_len().
    
    All lookup_hash() callers already checked permission in LOOKUP_PARENT walk.
    
    Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/namei.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 82f9568..907e247 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1849,13 +1849,7 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
 static struct dentry *__lookup_hash(struct qstr *name,
 		struct dentry *base, struct nameidata *nd)
 {
-	struct inode *inode = base->d_inode;
 	struct dentry *dentry;
-	int err;
-
-	err = inode_permission(inode, MAY_EXEC);
-	if (err)
-		return ERR_PTR(err);
 
 	/*
 	 * Don't bother with __d_lookup: callers are for creat as
@@ -1922,6 +1916,7 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
 {
 	struct qstr this;
 	unsigned int c;
+	int err;
 
 	WARN_ON_ONCE(!mutex_is_locked(&base->d_inode->i_mutex));
 
@@ -1946,6 +1941,10 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
 			return ERR_PTR(err);
 	}
 
+	err = inode_permission(base->d_inode, MAY_EXEC);
+	if (err)
+		return ERR_PTR(err);
+
 	return __lookup_hash(&this, base, NULL);
 }
 
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic