History

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.

Sahitya Tummala committed 7 years ago

Commit fbbf7791 parent 8223ecc1 file · +2 −2Browse files

Unified · Split

fs/f2fs/file.c+2−2
@@ -2264,9 +2264,9 @@ static int f2fs_ioc_gc_range(struct file *filp, unsigned long arg) · 2263 unmodified lines
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)