Skip to content

Commit

Permalink
f2fs: check cap_resource only for data blocks
Browse files Browse the repository at this point in the history
This patch changes the rule to check cap_resource for data blocks, not inode
or node blocks in order to avoid selinux denial.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
  • Loading branch information
Jaegeuk Kim committed May 2, 2018
1 parent b87078a commit a90a088
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fs/f2fs/f2fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1614,7 +1614,7 @@ static inline bool f2fs_has_xattr_block(unsigned int ofs)
}

static inline bool __allow_reserved_blocks(struct f2fs_sb_info *sbi,
struct inode *inode)
struct inode *inode, bool cap)
{
if (!inode)
return true;
Expand All @@ -1627,7 +1627,7 @@ static inline bool __allow_reserved_blocks(struct f2fs_sb_info *sbi,
if (!gid_eq(F2FS_OPTION(sbi).s_resgid, GLOBAL_ROOT_GID) &&
in_group_p(F2FS_OPTION(sbi).s_resgid))
return true;
if (capable(CAP_SYS_RESOURCE))
if (cap && capable(CAP_SYS_RESOURCE))
return true;
return false;
}
Expand Down Expand Up @@ -1662,7 +1662,7 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,
avail_user_block_count = sbi->user_block_count -
sbi->current_reserved_blocks;

if (!__allow_reserved_blocks(sbi, inode))
if (!__allow_reserved_blocks(sbi, inode, true))
avail_user_block_count -= F2FS_OPTION(sbi).root_reserved_blocks;

if (unlikely(sbi->total_valid_block_count > avail_user_block_count)) {
Expand Down Expand Up @@ -1869,7 +1869,7 @@ static inline int inc_valid_node_count(struct f2fs_sb_info *sbi,
valid_block_count = sbi->total_valid_block_count +
sbi->current_reserved_blocks + 1;

if (!__allow_reserved_blocks(sbi, inode))
if (!__allow_reserved_blocks(sbi, inode, false))
valid_block_count += F2FS_OPTION(sbi).root_reserved_blocks;

if (unlikely(valid_block_count > sbi->user_block_count)) {
Expand Down

0 comments on commit a90a088

Please sign in to comment.