In the Linux kernel, the following vulnerability has been resolved:
hfs/hfsplus: fix slab-out-of-bounds in hfsbnoderead_key
Syzbot reported an issue in hfs subsystem:
BUG: KASAN: slab-out-of-bounds in memcpyfrompage include/linux/highmem.h:423 [inline] BUG: KASAN: slab-out-of-bounds in hfsbnoderead fs/hfs/bnode.c:35 [inline] BUG: KASAN: slab-out-of-bounds in hfsbnoderead_key+0x314/0x450 fs/hfs/bnode.c:70 Write of size 94 at addr ffff8880123cd100 by task syz-executor237/5102
Call Trace: <TASK> _dumpstack lib/dumpstack.c:94 [inline] dumpstacklvl+0x241/0x360 lib/dumpstack.c:120 printaddressdescription mm/kasan/report.c:377 [inline] printreport+0x169/0x550 mm/kasan/report.c:488 kasanreport+0x143/0x180 mm/kasan/report.c:601 kasancheckrange+0x282/0x290 mm/kasan/generic.c:189 _asanmemcpy+0x40/0x70 mm/kasan/shadow.c:106 memcpyfrompage include/linux/highmem.h:423 [inline] hfsbnoderead fs/hfs/bnode.c:35 [inline] hfsbnodereadkey+0x314/0x450 fs/hfs/bnode.c:70 hfsbrecinsert+0x7f3/0xbd0 fs/hfs/brec.c:159 hfscatcreate+0x41d/0xa50 fs/hfs/catalog.c:118 hfsmkdir+0x6c/0xe0 fs/hfs/dir.c:232 vfsmkdir+0x2f9/0x4f0 fs/namei.c:4257 domkdirat+0x264/0x3a0 fs/namei.c:4280 _dosysmkdir fs/namei.c:4300 [inline] _sesysmkdir fs/namei.c:4298 [inline] _x64sysmkdir+0x6c/0x80 fs/namei.c:4298 dosyscallx64 arch/x86/entry/common.c:52 [inline] dosyscall64+0xf3/0x230 arch/x86/entry/common.c:83 entrySYSCALL64after_hwframe+0x77/0x7f RIP: 0033:0x7fbdd6057a99
Add a check for key length in hfsbnoderead_key to prevent out-of-bounds memory access. If the key length is invalid, the key buffer is cleared, improving stability and reliability.