Skip to content

Commit

Permalink
->permission() sanitizing: pass MAY_NOT_BLOCK to ->check_acl()
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Jul 20, 2011
1 parent 1fc0f78 commit 9c2c703
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion fs/9p/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int v9fs_check_acl(struct inode *inode, int mask, unsigned int flags)
struct posix_acl *acl;
struct v9fs_session_info *v9ses;

if (flags & IPERM_FLAG_RCU)
if (mask & MAY_NOT_BLOCK)
return -ECHILD;

v9ses = v9fs_inode2v9ses(inode);
Expand Down
3 changes: 1 addition & 2 deletions fs/btrfs/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,9 @@ int btrfs_check_acl(struct inode *inode, int mask, unsigned int flags)
{
int error = -EAGAIN;

if (flags & IPERM_FLAG_RCU) {
if (mask & MAY_NOT_BLOCK) {
if (!negative_cached_acl(inode, ACL_TYPE_ACCESS))
error = -ECHILD;

} else {
struct posix_acl *acl;
acl = btrfs_get_acl(inode, ACL_TYPE_ACCESS);
Expand Down
2 changes: 1 addition & 1 deletion fs/ext2/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ ext2_check_acl(struct inode *inode, int mask, unsigned int flags)
{
struct posix_acl *acl;

if (flags & IPERM_FLAG_RCU) {
if (mask & MAY_NOT_BLOCK) {
if (!negative_cached_acl(inode, ACL_TYPE_ACCESS))
return -ECHILD;
return -EAGAIN;
Expand Down
2 changes: 1 addition & 1 deletion fs/ext3/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ ext3_check_acl(struct inode *inode, int mask, unsigned int flags)
{
struct posix_acl *acl;

if (flags & IPERM_FLAG_RCU) {
if (mask & MAY_NOT_BLOCK) {
if (!negative_cached_acl(inode, ACL_TYPE_ACCESS))
return -ECHILD;
return -EAGAIN;
Expand Down
2 changes: 1 addition & 1 deletion fs/ext4/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ ext4_check_acl(struct inode *inode, int mask, unsigned int flags)
{
struct posix_acl *acl;

if (flags & IPERM_FLAG_RCU) {
if (mask & MAY_NOT_BLOCK) {
if (!negative_cached_acl(inode, ACL_TYPE_ACCESS))
return -ECHILD;
return -EAGAIN;
Expand Down
2 changes: 1 addition & 1 deletion fs/generic_acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ generic_acl_chmod(struct inode *inode)
int
generic_check_acl(struct inode *inode, int mask, unsigned int flags)
{
if (flags & IPERM_FLAG_RCU) {
if (mask & MAY_NOT_BLOCK) {
if (!negative_cached_acl(inode, ACL_TYPE_ACCESS))
return -ECHILD;
} else {
Expand Down
2 changes: 1 addition & 1 deletion fs/gfs2/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int gfs2_check_acl(struct inode *inode, int mask, unsigned int flags)
struct posix_acl *acl;
int error;

if (flags & IPERM_FLAG_RCU) {
if (mask & MAY_NOT_BLOCK) {
if (!negative_cached_acl(inode, ACL_TYPE_ACCESS))
return -ECHILD;
return -EAGAIN;
Expand Down
2 changes: 1 addition & 1 deletion fs/jffs2/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ int jffs2_check_acl(struct inode *inode, int mask, unsigned int flags)
struct posix_acl *acl;
int rc;

if (flags & IPERM_FLAG_RCU)
if (mask & MAY_NOT_BLOCK)
return -ECHILD;

acl = jffs2_get_acl(inode, ACL_TYPE_ACCESS);
Expand Down
2 changes: 1 addition & 1 deletion fs/jfs/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ int jfs_check_acl(struct inode *inode, int mask, unsigned int flags)
{
struct posix_acl *acl;

if (flags & IPERM_FLAG_RCU)
if (mask & MAY_NOT_BLOCK)
return -ECHILD;

acl = jfs_get_acl(inode, ACL_TYPE_ACCESS);
Expand Down
4 changes: 2 additions & 2 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static int acl_permission_check(struct inode *inode, int mask, unsigned int flag
int (*check_acl)(struct inode *inode, int mask, unsigned int flags);
unsigned int mode = inode->i_mode;

mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
mask &= MAY_READ | MAY_WRITE | MAY_EXEC | MAY_NOT_BLOCK;

if (current_user_ns() != inode_userns(inode))
goto other_perms;
Expand All @@ -204,7 +204,7 @@ static int acl_permission_check(struct inode *inode, int mask, unsigned int flag
/*
* If the DACs are ok we don't need any capability check.
*/
if ((mask & ~mode) == 0)
if ((mask & ~mode & (MAY_READ | MAY_WRITE | MAY_EXEC)) == 0)
return 0;
return -EACCES;
}
Expand Down
2 changes: 1 addition & 1 deletion fs/ocfs2/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ int ocfs2_check_acl(struct inode *inode, int mask, unsigned int flags)
struct posix_acl *acl;
int ret = -EAGAIN;

if (flags & IPERM_FLAG_RCU)
if (mask & MAY_NOT_BLOCK)
return -ECHILD;

osb = OCFS2_SB(inode->i_sb);
Expand Down
2 changes: 1 addition & 1 deletion fs/reiserfs/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ int reiserfs_check_acl(struct inode *inode, int mask, unsigned int flags)
if (get_inode_sd_version(inode) == STAT_DATA_V1)
return -EAGAIN;

if (flags & IPERM_FLAG_RCU)
if (mask & MAY_NOT_BLOCK)
return -ECHILD;

acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS);
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/linux-2.6/xfs_acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ xfs_check_acl(struct inode *inode, int mask, unsigned int flags)
if (!XFS_IFORK_Q(ip))
return -EAGAIN;

if (flags & IPERM_FLAG_RCU) {
if (mask & MAY_NOT_BLOCK) {
if (!negative_cached_acl(inode, ACL_TYPE_ACCESS))
return -ECHILD;
return -EAGAIN;
Expand Down

0 comments on commit 9c2c703

Please sign in to comment.