Skip to content

Commit

Permalink
->permission() sanitizing: don't pass flags to generic_permission()
Browse files Browse the repository at this point in the history
redundant; all callers get it duplicated in mask & MAY_NOT_BLOCK and none of
them removes that bit.

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Jul 20, 2011
1 parent 7e40145 commit 2830ba7
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion fs/afs/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ int afs_permission(struct inode *inode, int mask, unsigned int flags)
}

key_put(key);
ret = generic_permission(inode, mask, flags);
ret = generic_permission(inode, mask);
_leave(" = %d", ret);
return ret;

Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -7339,7 +7339,7 @@ static int btrfs_permission(struct inode *inode, int mask, unsigned int flags)
return -EROFS;
if ((BTRFS_I(inode)->flags & BTRFS_INODE_READONLY) && (mask & MAY_WRITE))
return -EACCES;
return generic_permission(inode, mask, flags);
return generic_permission(inode, mask);
}

static const struct inode_operations btrfs_dir_inode_operations = {
Expand Down
2 changes: 1 addition & 1 deletion fs/ceph/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,7 @@ int ceph_permission(struct inode *inode, int mask, unsigned int flags)
err = ceph_do_getattr(inode, CEPH_CAP_AUTH_SHARED);

if (!err)
err = generic_permission(inode, mask, flags);
err = generic_permission(inode, mask);
return err;
}

Expand Down
2 changes: 1 addition & 1 deletion fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ static int cifs_permission(struct inode *inode, int mask, unsigned int flags)
on the client (above and beyond ACL on servers) for
servers which do not support setting and viewing mode bits,
so allowing client to check permissions is useful */
return generic_permission(inode, mask, flags);
return generic_permission(inode, mask);
}

static struct kmem_cache *cifs_inode_cachep;
Expand Down
5 changes: 2 additions & 3 deletions fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,16 +1018,15 @@ static int fuse_permission(struct inode *inode, int mask, unsigned int flags)
}

if (fc->flags & FUSE_DEFAULT_PERMISSIONS) {
err = generic_permission(inode, mask, flags);
err = generic_permission(inode, mask);

/* If permission is denied, try to refresh file
attributes. This is also needed, because the root
node will at first have no permissions */
if (err == -EACCES && !refreshed) {
err = fuse_perm_getattr(inode, flags);
if (!err)
err = generic_permission(inode, mask,
flags);
err = generic_permission(inode, mask);
}

/* Note: the opposite of the above test does not
Expand Down
2 changes: 1 addition & 1 deletion fs/gfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ int gfs2_permission(struct inode *inode, int mask, unsigned int flags)
if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode))
error = -EACCES;
else
error = generic_permission(inode, mask, flags);
error = generic_permission(inode, mask);
if (unlock)
gfs2_glock_dq_uninit(&i_gh);

Expand Down
2 changes: 1 addition & 1 deletion fs/hostfs/hostfs_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ int hostfs_permission(struct inode *ino, int desired, unsigned int flags)
err = access_file(name, r, w, x);
__putname(name);
if (!err)
err = generic_permission(ino, desired, flags);
err = generic_permission(ino, desired);
return err;
}

Expand Down
2 changes: 1 addition & 1 deletion fs/hpfs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry)
hpfs_unlock(dir->i_sb);
return -ENOSPC;
}
if (generic_permission(inode, MAY_WRITE, 0) ||
if (generic_permission(inode, MAY_WRITE) ||
!S_ISREG(inode->i_mode) ||
get_write_access(inode)) {
d_rehash(dentry);
Expand Down
4 changes: 2 additions & 2 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ static int acl_permission_check(struct inode *inode, int mask)
* request cannot be satisfied (eg. requires blocking or too much complexity).
* It would then be called again in ref-walk mode.
*/
int generic_permission(struct inode *inode, int mask, unsigned int flags)
int generic_permission(struct inode *inode, int mask)
{
int ret;

Expand Down Expand Up @@ -289,7 +289,7 @@ int inode_permission(struct inode *inode, int mask)
if (inode->i_op->permission)
retval = inode->i_op->permission(inode, mask, 0);
else
retval = generic_permission(inode, mask, 0);
retval = generic_permission(inode, mask);

if (retval)
return retval;
Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -2328,7 +2328,7 @@ int nfs_permission(struct inode *inode, int mask, unsigned int flags)
out_notsup:
res = nfs_revalidate_inode(NFS_SERVER(inode), inode);
if (res == 0)
res = generic_permission(inode, mask, flags);
res = generic_permission(inode, mask);
goto out;
}

Expand Down
2 changes: 1 addition & 1 deletion fs/nilfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ int nilfs_permission(struct inode *inode, int mask, unsigned int flags)
root->cno != NILFS_CPTREE_CURRENT_CNO)
return -EROFS; /* snapshot is not writable */

return generic_permission(inode, mask, flags);
return generic_permission(inode, mask);
}

int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh)
Expand Down
2 changes: 1 addition & 1 deletion fs/ocfs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ int ocfs2_permission(struct inode *inode, int mask, unsigned int flags)
goto out;
}

ret = generic_permission(inode, mask, flags);
ret = generic_permission(inode, mask);

ocfs2_inode_unlock(inode, 0);
out:
Expand Down
2 changes: 1 addition & 1 deletion fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -2169,7 +2169,7 @@ static const struct file_operations proc_fd_operations = {
*/
static int proc_fd_permission(struct inode *inode, int mask, unsigned int flags)
{
int rv = generic_permission(inode, mask, flags);
int rv = generic_permission(inode, mask);
if (rv == 0)
return 0;
if (task_pid(current) == proc_pid(inode))
Expand Down
2 changes: 1 addition & 1 deletion fs/reiserfs/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ int reiserfs_permission(struct inode *inode, int mask, unsigned int flags)
if (IS_PRIVATE(inode))
return 0;

return generic_permission(inode, mask, flags);
return generic_permission(inode, mask);
}

static int xattr_hide_revalidate(struct dentry *dentry, struct nameidata *nd)
Expand Down
2 changes: 1 addition & 1 deletion fs/sysfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,5 +362,5 @@ int sysfs_permission(struct inode *inode, int mask, unsigned int flags)
sysfs_refresh_inode(sd, inode);
mutex_unlock(&sysfs_mutex);

return generic_permission(inode, mask, flags);
return generic_permission(inode, mask);
}
2 changes: 1 addition & 1 deletion include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2188,7 +2188,7 @@ extern sector_t bmap(struct inode *, sector_t);
#endif
extern int notify_change(struct dentry *, struct iattr *);
extern int inode_permission(struct inode *, int);
extern int generic_permission(struct inode *, int, unsigned int);
extern int generic_permission(struct inode *, int);

static inline bool execute_ok(struct inode *inode)
{
Expand Down

0 comments on commit 2830ba7

Please sign in to comment.