Skip to content

Commit fbbf779

Browse files
Sahitya TummalaJaegeuk Kim
authored andcommitted
f2fs: add a condition to detect overflow in f2fs_ioc_gc_range()
end = range.start + range.len; If the range.start/range.len is a very large value, then end can overflow in this operation. It results into a crash in get_valid_blocks() when accessing the invalid range.start segno. This issue is reported in ioctl fuzz testing. Signed-off-by: Sahitya Tummala <stummala@codeaurora.org> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 8223ecc commit fbbf779

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎fs/f2fs/file.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,9 +2264,9 @@ static int f2fs_ioc_gc_range(struct file *filp, unsigned long arg)
22642264
return -EROFS;
22652265

22662266
end = range.start + range.len;
2267-
if (range.start < MAIN_BLKADDR(sbi) || end >= MAX_BLKADDR(sbi)) {
2267+
if (end < range.start || range.start < MAIN_BLKADDR(sbi) ||
2268+
end >= MAX_BLKADDR(sbi))
22682269
return -EINVAL;
2269-
}
22702270

22712271
ret = mnt_want_write_file(filp);
22722272
if (ret)

0 commit comments

Comments
 (0)