aboutsummaryrefslogtreecommitdiff
path: root/fs/f2fs/file.c
diff options
context:
space:
mode:
authorSheng Yong <shengyong1@huawei.com>2017-03-08 10:47:12 +0800
committerMoyster <oysterized@gmail.com>2017-05-21 18:38:02 +0200
commitb888bbe3d6c1ab7a77d03fe7e899730fd31e2ecc (patch)
treeb80e1dcb2bb3b7b2851ee97cbdc74690f5a5d5dc /fs/f2fs/file.c
parent9730aaade1cde50c4ce18d0a3483bb257ff43c40 (diff)
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: Sheng Yong <shengyong1@huawei.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/file.c')
-rw-r--r--fs/f2fs/file.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index d7214fbfc..c5dbe9ff8 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2086,6 +2086,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)