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

Commit 1941d7bc authored by Sheng Yong's avatar Sheng Yong Committed by Jaegeuk Kim
Browse files

f2fs: check range before defragment



This patch checks the parameter range passed by ioctl to void that range
exceeds the max_file_blocks limit.

Signed-off-by: default avatarSheng Yong <shengyong1@huawei.com>
Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent b0beab50
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2054,6 +2054,12 @@ static int f2fs_ioc_defragment(struct file *filp, unsigned long arg)
		goto out;
	}

	if (unlikely((range.start + range.len) >> PAGE_SHIFT >
					sbi->max_file_blocks)) {
		err = -EINVAL;
		goto out;
	}

	err = f2fs_defragment_range(sbi, filp, &range);
	f2fs_update_time(sbi, REQ_TIME);
	if (err < 0)