syzbot


KASAN: slab-use-after-free Read in cmp_fnames

Status: moderation: reported on 2024/04/30 16:17
Subsystems: ntfs3
[Documentation on labels]
Reported-by: syzbot+f870a992bc9f5966c9d8@syzkaller.appspotmail.com
First crash: 21d, last: 21d

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in cmp_fnames+0x273/0x280 fs/ntfs3/index.c:50
Read of size 2 at addr ffff88802247cc9c by task syz-executor.1/7183

CPU: 0 PID: 7183 Comm: syz-executor.1 Not tainted 6.9.0-rc6-syzkaller-00022-g98369dccd2f8 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
 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
 cmp_fnames+0x273/0x280 fs/ntfs3/index.c:50
 hdr_find_e+0x352/0x630 fs/ntfs3/index.c:762
 indx_find+0x4fc/0xbf0 fs/ntfs3/index.c:1188
 indx_update_dup+0x485/0x860 fs/ntfs3/index.c:2659
 ni_update_parent+0xa18/0xdd0 fs/ntfs3/frecord.c:3233
 ni_write_inode+0xde9/0x1010 fs/ntfs3/frecord.c:3324
 ntfs_truncate fs/ntfs3/file.c:410 [inline]
 ntfs3_setattr+0x950/0xb40 fs/ntfs3/file.c:703
 notify_change+0xb9d/0xe70 fs/attr.c:497
 do_truncate+0x220/0x310 fs/open.c:65
 handle_truncate fs/namei.c:3300 [inline]
 do_open fs/namei.c:3646 [inline]
 path_openat+0x29fe/0x3240 fs/namei.c:3799
 do_filp_open+0x235/0x490 fs/namei.c:3826
 do_sys_openat2+0x13e/0x1d0 fs/open.c:1406
 do_sys_open fs/open.c:1421 [inline]
 __do_sys_openat fs/open.c:1437 [inline]
 __se_sys_openat fs/open.c:1432 [inline]
 __x64_sys_openat+0x247/0x2a0 fs/open.c:1432
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f7c94e7dea9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f7c949bd0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007f7c94fac120 RCX: 00007f7c94e7dea9
RDX: 000000000000275a RSI: 0000000020000180 RDI: ffffffffffffff9c
RBP: 00007f7c94eca4a4 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000006e R14: 00007f7c94fac120 R15: 00007ffd2b8a80d8
 </TASK>

Allocated by task 7168:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:370 [inline]
 __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:387
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 kmalloc_trace+0x1db/0x360 mm/slub.c:3997
 kmalloc include/linux/slab.h:628 [inline]
 kzalloc include/linux/slab.h:749 [inline]
 __ntfs_init_fs_context fs/ntfs3/super.c:1746 [inline]
 ntfs_init_fs_context+0x55/0x4a0 fs/ntfs3/super.c:1791
 alloc_fs_context+0x68a/0x800 fs/fs_context.c:318
 do_new_mount+0x160/0xb40 fs/namespace.c:3331
 do_mount fs/namespace.c:3692 [inline]
 __do_sys_mount fs/namespace.c:3898 [inline]
 __se_sys_mount+0x2d9/0x3c0 fs/namespace.c:3875
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 7168:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579
 poison_slab_object+0xa6/0xe0 mm/kasan/common.c:240
 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2106 [inline]
 slab_free mm/slub.c:4280 [inline]
 kfree+0x153/0x3a0 mm/slub.c:4390
 vfs_clean_context+0xaa/0x230 fs/fs_context.c:738
 vfs_cmd_reconfigure fs/fsopen.c:274 [inline]
 vfs_fsconfig_locked fs/fsopen.c:296 [inline]
 __do_sys_fsconfig fs/fsopen.c:476 [inline]
 __se_sys_fsconfig+0xd76/0xec0 fs/fsopen.c:349
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff88802247cc80
 which belongs to the cache kmalloc-32 of size 32
The buggy address is located 28 bytes inside of
 freed 32-byte region [ffff88802247cc80, ffff88802247cca0)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88802247cb40 pfn:0x2247c
flags: 0xfff00000000a00(workingset|slab|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000a00 ffff888015041500 ffffea00008a2b50 ffffea00008f2a90
raw: ffff88802247cb40 0000000000400035 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 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 5323, tgid -588364120 (syz-executor.0), ts 5323, free_ts 85218614352
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1ea/0x210 mm/page_alloc.c:1534
 prep_new_page mm/page_alloc.c:1541 [inline]
 get_page_from_freelist+0x3410/0x35b0 mm/page_alloc.c:3317
 __alloc_pages+0x256/0x6c0 mm/page_alloc.c:4575
 __alloc_pages_node include/linux/gfp.h:238 [inline]
 alloc_pages_node include/linux/gfp.h:261 [inline]
 alloc_slab_page+0x5f/0x160 mm/slub.c:2175
 allocate_slab mm/slub.c:2338 [inline]
 new_slab+0x84/0x2f0 mm/slub.c:2391
 ___slab_alloc+0xc73/0x1260 mm/slub.c:3525
 __slab_alloc mm/slub.c:3610 [inline]
 __slab_alloc_node mm/slub.c:3663 [inline]
 slab_alloc_node mm/slub.c:3835 [inline]
 kmalloc_trace+0x269/0x360 mm/slub.c:3992
 kmalloc include/linux/slab.h:628 [inline]
 kzalloc include/linux/slab.h:749 [inline]
 ref_tracker_alloc+0x14b/0x490 lib/ref_tracker.c:203
 __netdev_tracker_alloc include/linux/netdevice.h:4064 [inline]
 netdev_hold include/linux/netdevice.h:4093 [inline]
 qdisc_alloc+0x72a/0x990 net/sched/sch_generic.c:978
 qdisc_create_dflt+0x62/0x4b0 net/sched/sch_generic.c:1000
 attach_one_default_qdisc net/sched/sch_generic.c:1165 [inline]
 netdev_for_each_tx_queue include/linux/netdevice.h:2500 [inline]
 attach_default_qdiscs net/sched/sch_generic.c:1183 [inline]
 dev_activate+0x3c0/0x1240 net/sched/sch_generic.c:1242
 __dev_open+0x352/0x450 net/core/dev.c:1439
 __dev_change_flags+0x1e2/0x6f0 net/core/dev.c:8692
 dev_change_flags+0x8b/0x1a0 net/core/dev.c:8764
 do_setlink+0xccd/0x41f0 net/core/rtnetlink.c:2884
 __rtnl_newlink net/core/rtnetlink.c:3680 [inline]
 rtnl_newlink+0x180b/0x20a0 net/core/rtnetlink.c:3727
page last free pid 5576 tgid 5576 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1141 [inline]
 free_unref_page_prepare+0x97b/0xaa0 mm/page_alloc.c:2347
 free_unref_folios+0x1f2/0xc10 mm/page_alloc.c:2536
 folios_put_refs+0x93a/0xa60 mm/swap.c:1034
 free_pages_and_swap_cache+0x2ea/0x690 mm/swap_state.c:329
 __tlb_batch_free_encoded_pages mm/mmu_gather.c:136 [inline]
 tlb_batch_pages_flush mm/mmu_gather.c:149 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:366 [inline]
 tlb_flush_mmu+0x3a3/0x680 mm/mmu_gather.c:373
 tlb_finish_mmu+0xd4/0x200 mm/mmu_gather.c:465
 exit_mmap+0x4bb/0xd60 mm/mmap.c:3280
 __mmput+0x115/0x3c0 kernel/fork.c:1346
 exit_mm+0x220/0x310 kernel/exit.c:569
 do_exit+0x99e/0x27e0 kernel/exit.c:865
 do_group_exit+0x207/0x2c0 kernel/exit.c:1027
 __do_sys_exit_group kernel/exit.c:1038 [inline]
 __se_sys_exit_group kernel/exit.c:1036 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1036
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
 ffff88802247cb80: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc
 ffff88802247cc00: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc
>ffff88802247cc80: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
                            ^
 ffff88802247cd00: fa fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc
 ffff88802247cd80: 00 00 00 fc fc fc fc fc fa fb fb fb fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/04/30 16:07 upstream 98369dccd2f8 3ce4924c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in cmp_fnames
* Struck through repros no longer work on HEAD.