Commit f419a2e3 authored by Al Viro's avatar Al Viro

[PATCH] kill nameidata passing to permission(), rename to inode_permission()

Incidentally, the name that gives hundreds of false positives on grep
is not a good idea...
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 30524472
...@@ -830,7 +830,7 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length) ...@@ -830,7 +830,7 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length)
static int static int
ecryptfs_permission(struct inode *inode, int mask) ecryptfs_permission(struct inode *inode, int mask)
{ {
return permission(ecryptfs_inode_to_lower(inode), mask, NULL); return inode_permission(ecryptfs_inode_to_lower(inode), mask);
} }
/** /**
......
...@@ -227,13 +227,9 @@ int generic_permission(struct inode *inode, int mask, ...@@ -227,13 +227,9 @@ int generic_permission(struct inode *inode, int mask,
return -EACCES; return -EACCES;
} }
int permission(struct inode *inode, int mask, struct nameidata *nd) int inode_permission(struct inode *inode, int mask)
{ {
int retval; int retval;
struct vfsmount *mnt = NULL;
if (nd)
mnt = nd->path.mnt;
if (mask & MAY_WRITE) { if (mask & MAY_WRITE) {
umode_t mode = inode->i_mode; umode_t mode = inode->i_mode;
...@@ -293,7 +289,7 @@ int permission(struct inode *inode, int mask, struct nameidata *nd) ...@@ -293,7 +289,7 @@ int permission(struct inode *inode, int mask, struct nameidata *nd)
*/ */
int vfs_permission(struct nameidata *nd, int mask) int vfs_permission(struct nameidata *nd, int mask)
{ {
return permission(nd->path.dentry->d_inode, mask, nd); return inode_permission(nd->path.dentry->d_inode, mask);
} }
/** /**
...@@ -310,7 +306,7 @@ int vfs_permission(struct nameidata *nd, int mask) ...@@ -310,7 +306,7 @@ int vfs_permission(struct nameidata *nd, int mask)
*/ */
int file_permission(struct file *file, int mask) int file_permission(struct file *file, int mask)
{ {
return permission(file->f_path.dentry->d_inode, mask, NULL); return inode_permission(file->f_path.dentry->d_inode, mask);
} }
/* /*
...@@ -1262,7 +1258,7 @@ static struct dentry *lookup_hash(struct nameidata *nd) ...@@ -1262,7 +1258,7 @@ static struct dentry *lookup_hash(struct nameidata *nd)
{ {
int err; int err;
err = permission(nd->path.dentry->d_inode, MAY_EXEC, nd); err = inode_permission(nd->path.dentry->d_inode, MAY_EXEC);
if (err) if (err)
return ERR_PTR(err); return ERR_PTR(err);
return __lookup_hash(&nd->last, nd->path.dentry, nd); return __lookup_hash(&nd->last, nd->path.dentry, nd);
...@@ -1310,7 +1306,7 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len) ...@@ -1310,7 +1306,7 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
if (err) if (err)
return ERR_PTR(err); return ERR_PTR(err);
err = permission(base->d_inode, MAY_EXEC, NULL); err = inode_permission(base->d_inode, MAY_EXEC);
if (err) if (err)
return ERR_PTR(err); return ERR_PTR(err);
return __lookup_hash(&this, base, NULL); return __lookup_hash(&this, base, NULL);
...@@ -1400,7 +1396,7 @@ static int may_delete(struct inode *dir,struct dentry *victim,int isdir) ...@@ -1400,7 +1396,7 @@ static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
BUG_ON(victim->d_parent->d_inode != dir); BUG_ON(victim->d_parent->d_inode != dir);
audit_inode_child(victim->d_name.name, victim, dir); audit_inode_child(victim->d_name.name, victim, dir);
error = permission(dir,MAY_WRITE | MAY_EXEC, NULL); error = inode_permission(dir, MAY_WRITE | MAY_EXEC);
if (error) if (error)
return error; return error;
if (IS_APPEND(dir)) if (IS_APPEND(dir))
...@@ -1437,7 +1433,7 @@ static inline int may_create(struct inode *dir, struct dentry *child, ...@@ -1437,7 +1433,7 @@ static inline int may_create(struct inode *dir, struct dentry *child,
return -EEXIST; return -EEXIST;
if (IS_DEADDIR(dir)) if (IS_DEADDIR(dir))
return -ENOENT; return -ENOENT;
return permission(dir,MAY_WRITE | MAY_EXEC, nd); return inode_permission(dir, MAY_WRITE | MAY_EXEC);
} }
/* /*
...@@ -2543,7 +2539,7 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, ...@@ -2543,7 +2539,7 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
* we'll need to flip '..'. * we'll need to flip '..'.
*/ */
if (new_dir != old_dir) { if (new_dir != old_dir) {
error = permission(old_dentry->d_inode, MAY_WRITE, NULL); error = inode_permission(old_dentry->d_inode, MAY_WRITE);
if (error) if (error)
return error; return error;
} }
...@@ -2897,7 +2893,7 @@ EXPORT_SYMBOL(page_symlink); ...@@ -2897,7 +2893,7 @@ EXPORT_SYMBOL(page_symlink);
EXPORT_SYMBOL(page_symlink_inode_operations); EXPORT_SYMBOL(page_symlink_inode_operations);
EXPORT_SYMBOL(path_lookup); EXPORT_SYMBOL(path_lookup);
EXPORT_SYMBOL(vfs_path_lookup); EXPORT_SYMBOL(vfs_path_lookup);
EXPORT_SYMBOL(permission); EXPORT_SYMBOL(inode_permission);
EXPORT_SYMBOL(vfs_permission); EXPORT_SYMBOL(vfs_permission);
EXPORT_SYMBOL(file_permission); EXPORT_SYMBOL(file_permission);
EXPORT_SYMBOL(unlock_rename); EXPORT_SYMBOL(unlock_rename);
......
...@@ -51,7 +51,7 @@ static int nfsd_acceptable(void *expv, struct dentry *dentry) ...@@ -51,7 +51,7 @@ static int nfsd_acceptable(void *expv, struct dentry *dentry)
/* make sure parents give x permission to user */ /* make sure parents give x permission to user */
int err; int err;
parent = dget_parent(tdentry); parent = dget_parent(tdentry);
err = permission(parent->d_inode, MAY_EXEC, NULL); err = inode_permission(parent->d_inode, MAY_EXEC);
if (err < 0) { if (err < 0) {
dput(parent); dput(parent);
break; break;
......
...@@ -1953,12 +1953,12 @@ nfsd_permission(struct svc_rqst *rqstp, struct svc_export *exp, ...@@ -1953,12 +1953,12 @@ nfsd_permission(struct svc_rqst *rqstp, struct svc_export *exp,
return 0; return 0;
/* This assumes NFSD_MAY_{READ,WRITE,EXEC} == MAY_{READ,WRITE,EXEC} */ /* This assumes NFSD_MAY_{READ,WRITE,EXEC} == MAY_{READ,WRITE,EXEC} */
err = permission(inode, acc & (MAY_READ|MAY_WRITE|MAY_EXEC), NULL); err = inode_permission(inode, acc & (MAY_READ|MAY_WRITE|MAY_EXEC));
/* Allow read access to binaries even when mode 111 */ /* Allow read access to binaries even when mode 111 */
if (err == -EACCES && S_ISREG(inode->i_mode) && if (err == -EACCES && S_ISREG(inode->i_mode) &&
acc == (NFSD_MAY_READ | NFSD_MAY_OWNER_OVERRIDE)) acc == (NFSD_MAY_READ | NFSD_MAY_OWNER_OVERRIDE))
err = permission(inode, MAY_EXEC, NULL); err = inode_permission(inode, MAY_EXEC);
return err? nfserrno(err) : 0; return err? nfserrno(err) : 0;
} }
......
...@@ -96,7 +96,7 @@ static int utimes_common(struct path *path, struct timespec *times) ...@@ -96,7 +96,7 @@ static int utimes_common(struct path *path, struct timespec *times)
goto mnt_drop_write_and_out; goto mnt_drop_write_and_out;
if (!is_owner_or_cap(inode)) { if (!is_owner_or_cap(inode)) {
error = permission(inode, MAY_WRITE, NULL); error = inode_permission(inode, MAY_WRITE);
if (error) if (error)
goto mnt_drop_write_and_out; goto mnt_drop_write_and_out;
} }
......
...@@ -63,7 +63,7 @@ xattr_permission(struct inode *inode, const char *name, int mask) ...@@ -63,7 +63,7 @@ xattr_permission(struct inode *inode, const char *name, int mask)
return -EPERM; return -EPERM;
} }
return permission(inode, mask, NULL); return inode_permission(inode, mask);
} }
int int
......
...@@ -1770,7 +1770,7 @@ extern int do_remount_sb(struct super_block *sb, int flags, ...@@ -1770,7 +1770,7 @@ extern int do_remount_sb(struct super_block *sb, int flags,
extern sector_t bmap(struct inode *, sector_t); extern sector_t bmap(struct inode *, sector_t);
#endif #endif
extern int notify_change(struct dentry *, struct iattr *); extern int notify_change(struct dentry *, struct iattr *);
extern int permission(struct inode *, int, struct nameidata *); extern int inode_permission(struct inode *, int);
extern int generic_permission(struct inode *, int, extern int generic_permission(struct inode *, int,
int (*check_acl)(struct inode *, int)); int (*check_acl)(struct inode *, int));
......
...@@ -638,7 +638,7 @@ static int oflag2acc[O_ACCMODE] = { MAY_READ, MAY_WRITE, ...@@ -638,7 +638,7 @@ static int oflag2acc[O_ACCMODE] = { MAY_READ, MAY_WRITE,
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
if (permission(dentry->d_inode, oflag2acc[oflag & O_ACCMODE], NULL)) { if (inode_permission(dentry->d_inode, oflag2acc[oflag & O_ACCMODE])) {
dput(dentry); dput(dentry);
mntput(mqueue_mnt); mntput(mqueue_mnt);
return ERR_PTR(-EACCES); return ERR_PTR(-EACCES);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment