In the Linux kernel, the following vulnerability has been resolved:
exfat: check if cluster num is valid
Syzbot reported slab-out-of-bounds read in exfatclearbitmap. This was triggered by reproducer calling truncute with size 0, which causes the following trace:
BUG: KASAN: slab-out-of-bounds in exfatclearbitmap+0x147/0x490 fs/exfat/balloc.c:174 Read of size 8 at addr ffff888115aa9508 by task syz-executor251/365
Call Trace: _dumpstack lib/dumpstack.c:77 [inline] dumpstacklvl+0x1e2/0x24b lib/dumpstack.c:118 printaddressdescription+0x81/0x3c0 mm/kasan/report.c:233 _kasanreport mm/kasan/report.c:419 [inline] kasanreport+0x1a4/0x1f0 mm/kasan/report.c:436 _asanreportload8noabort+0x14/0x20 mm/kasan/reportgeneric.c:309 exfatclearbitmap+0x147/0x490 fs/exfat/balloc.c:174 exfatfreecluster+0x25a/0x4a0 fs/exfat/fatent.c:181 _exfattruncate+0x99e/0xe00 fs/exfat/file.c:217 exfattruncate+0x11b/0x4f0 fs/exfat/file.c:243 exfatsetattr+0xa03/0xd40 fs/exfat/file.c:339 notifychange+0xb76/0xe10 fs/attr.c:336 dotruncate+0x1ea/0x2d0 fs/open.c:65
Move the isvalidcluster() helper from fatent.c to a common header to make it reusable in other *.c files. And add isvalidcluster() to validate if cluster number is within valid range in exfatclearbitmap() and exfatsetbitmap().