syzbot


KASAN: slab-out-of-bounds Write in hfs_bnode_read_key

Status: upstream: reported C repro on 2023/06/04 20:20
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+4be1354b4526d3f6335d@syzkaller.appspotmail.com
First crash: 386d, last: 35d
Bug presence (1)
Date Name Commit Repro Result
2023/09/30 upstream (ToT) 9f3ebbef746f C [report] KASAN: slab-out-of-bounds Write in hfs_bnode_read_key
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-out-of-bounds Write in hfs_bnode_read_key hfs C error done 4 159d 382d 26/27 fixed on 2024/03/20 11:33
Fix bisection attempts (9)
Created Duration User Patch Repo Result
2024/05/20 01:22 1h08m bisect fix linux-6.1.y job log (0) log
2024/04/15 22:51 1h56m bisect fix linux-6.1.y job log (0) log
2024/03/13 04:56 1h23m bisect fix linux-6.1.y job log (0) log
2024/02/03 15:10 1h31m (2) bisect fix linux-6.1.y job log (0) log
2023/12/31 14:32 1h10m bisect fix linux-6.1.y job log (0) log
2023/12/01 08:19 1h11m bisect fix linux-6.1.y job log (0) log
2023/10/31 05:11 1h25m bisect fix linux-6.1.y job log (0) log
2023/09/30 00:38 1h20m bisect fix linux-6.1.y job log (0) log
2023/07/10 02:24 3h04m bisect fix linux-6.1.y job log (0) log

Sample crash report:
loop0: detected capacity change from 0 to 64
hfs: unable to locate alternate MDB
hfs: continuing without an alternate MDB
==================================================================
BUG: KASAN: slab-out-of-bounds in memcpy_from_page include/linux/highmem.h:393 [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+0x310/0x440 fs/hfs/bnode.c:70
Write of size 256 at addr ffff888016ec7c00 by task syz-executor246/3539

CPU: 0 PID: 3539 Comm: syz-executor246 Not tainted 6.1.42-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:284 [inline]
 print_report+0x15f/0x4f0 mm/kasan/report.c:395
 kasan_report+0x136/0x160 mm/kasan/report.c:495
 kasan_check_range+0x27f/0x290 mm/kasan/generic.c:189
 memcpy+0x3c/0x60 mm/kasan/shadow.c:66
 memcpy_from_page include/linux/highmem.h:393 [inline]
 hfs_bnode_read fs/hfs/bnode.c:35 [inline]
 hfs_bnode_read_key+0x310/0x440 fs/hfs/bnode.c:70
 hfs_brec_insert+0x69d/0xbd0 fs/hfs/brec.c:141
 hfs_cat_create+0x5db/0xa60 fs/hfs/catalog.c:131
 hfs_create+0x62/0xd0 fs/hfs/dir.c:202
 lookup_open fs/namei.c:3413 [inline]
 open_last_lookups fs/namei.c:3481 [inline]
 path_openat+0x12f1/0x2e60 fs/namei.c:3711
 do_filp_open+0x230/0x480 fs/namei.c:3741
 do_sys_openat2+0x13b/0x500 fs/open.c:1318
 do_sys_open fs/open.c:1334 [inline]
 __do_sys_openat fs/open.c:1350 [inline]
 __se_sys_openat fs/open.c:1345 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1345
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fe09674e979
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 61 17 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe8cf3ed48 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007fe09679705e RCX: 00007fe09674e979
RDX: 0000000000141842 RSI: 0000000020000380 RDI: 00000000ffffff9c
RBP: 00007fe096797068 R08: 0000000000000260 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00007ffe8cf3ef28 R14: 0000000000000001 R15: 0000000000000001
 </TASK>

Allocated by task 3539:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:383
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 __do_kmalloc_node mm/slab_common.c:955 [inline]
 __kmalloc+0xb2/0x230 mm/slab_common.c:968
 kmalloc include/linux/slab.h:558 [inline]
 hfs_find_init+0x8c/0x1e0 fs/hfs/bfind.c:21
 hfs_cat_create+0x17e/0xa60 fs/hfs/catalog.c:96
 hfs_create+0x62/0xd0 fs/hfs/dir.c:202
 lookup_open fs/namei.c:3413 [inline]
 open_last_lookups fs/namei.c:3481 [inline]
 path_openat+0x12f1/0x2e60 fs/namei.c:3711
 do_filp_open+0x230/0x480 fs/namei.c:3741
 do_sys_openat2+0x13b/0x500 fs/open.c:1318
 do_sys_open fs/open.c:1334 [inline]
 __do_sys_openat fs/open.c:1350 [inline]
 __se_sys_openat fs/open.c:1345 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1345
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff888016ec7c00
 which belongs to the cache kmalloc-96 of size 96
The buggy address is located 0 bytes inside of
 96-byte region [ffff888016ec7c00, ffff888016ec7c60)

The buggy address belongs to the physical page:
page:ffffea00005bb1c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x16ec7
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea00009d78c0 dead000000000002 ffff888012441780
raw: 0000000000000000 0000000080200020 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY), pid 3004, tgid 3004 (udevd), ts 17510288020, free_ts 17503128609
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2533
 prep_new_page mm/page_alloc.c:2540 [inline]
 get_page_from_freelist+0x32ed/0x3480 mm/page_alloc.c:4292
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5559
 alloc_slab_page+0x6a/0x150 mm/slub.c:1794
 allocate_slab mm/slub.c:1939 [inline]
 new_slab+0x84/0x2d0 mm/slub.c:1992
 ___slab_alloc+0xa71/0x1080 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 __kmem_cache_alloc_node+0x19f/0x260 mm/slub.c:3437
 __do_kmalloc_node mm/slab_common.c:954 [inline]
 __kmalloc+0xa1/0x230 mm/slab_common.c:968
 kmalloc include/linux/slab.h:558 [inline]
 kzalloc include/linux/slab.h:689 [inline]
 tomoyo_encode2 security/tomoyo/realpath.c:45 [inline]
 tomoyo_encode+0x26b/0x530 security/tomoyo/realpath.c:80
 tomoyo_realpath_from_path+0x594/0x5d0 security/tomoyo/realpath.c:283
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_check_open_permission+0x22c/0x490 security/tomoyo/file.c:771
 security_file_open+0x5f/0xa0 security/security.c:1649
 do_dentry_open+0x308/0x10f0 fs/open.c:869
 do_open fs/namei.c:3557 [inline]
 path_openat+0x2644/0x2e60 fs/namei.c:3714
 do_filp_open+0x230/0x480 fs/namei.c:3741
 do_sys_openat2+0x13b/0x500 fs/open.c:1318
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1460 [inline]
 free_pcp_prepare mm/page_alloc.c:1510 [inline]
 free_unref_page_prepare+0xf63/0x1120 mm/page_alloc.c:3388
 free_unref_page+0x98/0x570 mm/page_alloc.c:3484
 qlist_free_all+0x22/0x60 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x1f/0x70 mm/kasan/common.c:305
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook+0x50/0x370 mm/slab.h:737
 slab_alloc_node mm/slub.c:3398 [inline]
 slab_alloc mm/slub.c:3406 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
 kmem_cache_alloc+0x10c/0x2d0 mm/slub.c:3422
 getname_flags+0xb8/0x4e0 fs/namei.c:139
 vfs_fstatat fs/stat.c:266 [inline]
 __do_sys_newfstatat fs/stat.c:437 [inline]
 __se_sys_newfstatat fs/stat.c:431 [inline]
 __x64_sys_newfstatat+0x130/0x1e0 fs/stat.c:431
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Memory state around the buggy address:
 ffff888016ec7b00: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
 ffff888016ec7b80: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
>ffff888016ec7c00: 00 00 00 00 00 00 00 00 00 06 fc fc fc fc fc fc
                                              ^
 ffff888016ec7c80: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
 ffff888016ec7d00: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/07/30 13:51 linux-6.1.y d2a6dc4eaf6d 92476829 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-6-1-kasan KASAN: slab-out-of-bounds Write in hfs_bnode_read_key
2023/06/04 20:19 linux-6.1.y d2869ace6eeb a4ae4f42 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-6-1-kasan-arm64 KASAN: slab-out-of-bounds Write in hfs_bnode_read_key
* Struck through repros no longer work on HEAD.