linux-yocto/fs/hfsplus
Vasiliy Kovalev 84e8719c08 hfs/hfsplus: fix slab-out-of-bounds in hfs_bnode_read_key
commit bb5e07cb92 upstream.

Syzbot reported an issue in hfs subsystem:

BUG: KASAN: slab-out-of-bounds in memcpy_from_page include/linux/highmem.h:423 [inline]
BUG: KASAN: slab-out-of-bounds in hfs_bnode_read fs/hfs/bnode.c:35 [inline]
BUG: KASAN: slab-out-of-bounds in hfs_bnode_read_key+0x314/0x450 fs/hfs/bnode.c:70
Write of size 94 at addr ffff8880123cd100 by task syz-executor237/5102

Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report+0x143/0x180 mm/kasan/report.c:601
 kasan_check_range+0x282/0x290 mm/kasan/generic.c:189
 __asan_memcpy+0x40/0x70 mm/kasan/shadow.c:106
 memcpy_from_page include/linux/highmem.h:423 [inline]
 hfs_bnode_read fs/hfs/bnode.c:35 [inline]
 hfs_bnode_read_key+0x314/0x450 fs/hfs/bnode.c:70
 hfs_brec_insert+0x7f3/0xbd0 fs/hfs/brec.c:159
 hfs_cat_create+0x41d/0xa50 fs/hfs/catalog.c:118
 hfs_mkdir+0x6c/0xe0 fs/hfs/dir.c:232
 vfs_mkdir+0x2f9/0x4f0 fs/namei.c:4257
 do_mkdirat+0x264/0x3a0 fs/namei.c:4280
 __do_sys_mkdir fs/namei.c:4300 [inline]
 __se_sys_mkdir fs/namei.c:4298 [inline]
 __x64_sys_mkdir+0x6c/0x80 fs/namei.c:4298
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fbdd6057a99

Add a check for key length in hfs_bnode_read_key to prevent
out-of-bounds memory access. If the key length is invalid, the
key buffer is cleared, improving stability and reliability.

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Reported-by: syzbot+5f3a973ed3dfb85a6683@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=5f3a973ed3dfb85a6683
Cc: stable@vger.kernel.org
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
Link: https://lore.kernel.org/20241019191303.24048-1-kovalev@altlinux.org
Reviewed-by: Cengiz Can <cengiz.can@canonical.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-04-25 10:47:52 +02:00
..
attributes.c
bfind.c hfsplus: fix to avoid false alarm of circular locking 2024-06-21 11:41:04 +02:00
bitmap.c
bnode.c hfs/hfsplus: fix slab-out-of-bounds in hfs_bnode_read_key 2025-04-25 10:47:52 +02:00
brec.c
btree.c
catalog.c
dir.c
extents.c fs: Convert aops->write_begin to take a folio 2024-08-07 11:33:21 +02:00
hfsplus_fs.h hfsplus: don't query the device logical block size multiple times 2024-12-05 14:01:15 +01:00
hfsplus_raw.h
inode.c fs: Convert aops->write_begin to take a folio 2024-08-07 11:33:21 +02:00
ioctl.c vfs: rename parent_ino to d_parent_ino and make it use RCU 2024-06-27 18:34:21 +02:00
Kconfig
Makefile
options.c
part_tbl.c
super.c hfsplus: switch to rcu-delayed unloading of nls and freeing ->s_fs_info 2024-02-25 02:10:31 -05:00
tables.c
unicode.c
wrapper.c hfsplus: don't query the device logical block size multiple times 2024-12-05 14:01:15 +01:00
xattr_security.c
xattr_trusted.c
xattr_user.c
xattr.c hfsplus: fix uninit-value in copy_name 2024-07-06 09:19:31 +02:00
xattr.h