diff options
author | Sheng Yong | 2017-03-08 03:47:12 +0100 |
---|---|---|
committer | Jaegeuk Kim | 2017-03-22 03:34:25 +0100 |
commit | 1941d7bcb474aa38caca16e6d3416e623d37d800 (patch) | |
tree | e1e116b804e38e9be09c328f61696ec27e247a3b /fs | |
parent | f2fs: use parameter max_items instead of PIDVEC_SIZE (diff) | |
download | kernel-qcow2-linux-1941d7bcb474aa38caca16e6d3416e623d37d800.tar.gz kernel-qcow2-linux-1941d7bcb474aa38caca16e6d3416e623d37d800.tar.xz kernel-qcow2-linux-1941d7bcb474aa38caca16e6d3416e623d37d800.zip |
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')
-rw-r--r-- | fs/f2fs/file.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 427ab1b41de3..300d62015c24 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -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) |