提交 cda309de 编写于 作者: M Miklos Szeredi 提交者: Al Viro

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: NMiklos Szeredi <mszeredi@suse.cz>
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 3637c05d
...@@ -1849,13 +1849,7 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt, ...@@ -1849,13 +1849,7 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
static struct dentry *__lookup_hash(struct qstr *name, static struct dentry *__lookup_hash(struct qstr *name,
struct dentry *base, struct nameidata *nd) struct dentry *base, struct nameidata *nd)
{ {
struct inode *inode = base->d_inode;
struct dentry *dentry; 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 * 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) ...@@ -1922,6 +1916,7 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
{ {
struct qstr this; struct qstr this;
unsigned int c; unsigned int c;
int err;
WARN_ON_ONCE(!mutex_is_locked(&base->d_inode->i_mutex)); 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) ...@@ -1946,6 +1941,10 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
return ERR_PTR(err); return ERR_PTR(err);
} }
err = inode_permission(base->d_inode, MAY_EXEC);
if (err)
return ERR_PTR(err);
return __lookup_hash(&this, base, NULL); return __lookup_hash(&this, base, NULL);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册