Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b279e85e authored by Jaegeuk Kim's avatar Jaegeuk Kim Committed by Jaegeuk Kim
Browse files

f2fs: check cap_resource only for data blocks



Cherry-pick from origin/upstream-f2fs-stable-linux-3.18.y:
commit dae6d196 ("f2fs: check cap_resource only for data blocks")

This patch changes the rule to check cap_resource for data blocks, not inode
or node blocks in order to avoid selinux denial.

Change-Id: I02bc7b9eb78b64323d71cb945850b2c4828dcebd
Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 1d9d5c74
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -1707,7 +1707,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;
@@ -1720,7 +1720,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;
}
@@ -1755,7 +1755,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)) {
@@ -1962,7 +1962,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)) {