syzbot


KASAN: use-after-free Write in detach_if_pending

Status: premoderation: reported on 2024/10/18 20:02
Reported-by: syzbot+5f9c6c4ed9d81b487949@syzkaller.appspotmail.com
First crash: 33d, last: 33d
Similar bugs (7)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-54 KASAN: use-after-free Write in detach_if_pending C 494 140d 649d 0/2 upstream: reported C repro on 2023/02/10 18:19
upstream KASAN: use-after-free Write in detach_if_pending net C 4169 2587d 2582d 3/28 fixed on 2017/11/28 03:36
upstream general protection fault in detach_if_pending (2) net 1 984d 984d 0/28 auto-closed as invalid on 2022/06/11 02:46
linux-4.14 general protection fault in detach_if_pending (2) 1 1294d 1294d 0/1 auto-closed as invalid on 2021/09/04 11:36
upstream general protection fault in detach_if_pending (3) bcachefs kvm 5 149d 149d 0/28 closed as invalid on 2024/08/16 18:25
upstream KASAN: invalid-access Write in detach_if_pending wireguard 2 1374d 1375d 0/28 auto-closed as invalid on 2021/05/17 08:51
upstream KASAN: slab-use-after-free Write in detach_if_pending wireguard batman 2 566d 575d 0/28 auto-obsoleted due to no activity on 2023/11/08 05:10

Sample crash report:
tipc: Disabling bearer <udp:syz2>
tipc: Left network mode
==================================================================
BUG: KASAN: use-after-free in __hlist_del include/linux/list.h:886 [inline]
BUG: KASAN: use-after-free in detach_timer kernel/time/timer.c:886 [inline]
BUG: KASAN: use-after-free in detach_if_pending+0x1d3/0x390 kernel/time/timer.c:905
Write of size 8 at addr ffff8881168b24c0 by task kworker/u4:2/43

CPU: 1 PID: 43 Comm: kworker/u4:2 Not tainted 6.1.99-syzkaller-00048-g299cc91948f1 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Workqueue: netns cleanup_net
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0x158/0x4e0 mm/kasan/report.c:427
 kasan_report+0x13c/0x170 mm/kasan/report.c:531
 __asan_report_store8_noabort+0x17/0x20 mm/kasan/report_generic.c:356
 __hlist_del include/linux/list.h:886 [inline]
 detach_timer kernel/time/timer.c:886 [inline]
 detach_if_pending+0x1d3/0x390 kernel/time/timer.c:905
 del_timer+0xcf/0x140 kernel/time/timer.c:1287
 try_to_grab_pending+0xeb/0x5d0 kernel/workqueue.c:1285
 __cancel_work_timer+0x132/0x630 kernel/workqueue.c:3129
 cancel_delayed_work_sync+0x1a/0x20 kernel/workqueue.c:3311
 tipc_crypto_stop+0xa7/0x400 net/tipc/crypto.c:1524
 tipc_exit_net+0xf8/0x160 net/tipc/core.c:119
 ops_exit_list net/core/net_namespace.c:172 [inline]
 cleanup_net+0x64b/0xbf0 net/core/net_namespace.c:604
 process_one_work+0x73d/0xcb0 kernel/workqueue.c:2299
 worker_thread+0xa60/0x1260 kernel/workqueue.c:2446
 kthread+0x26d/0x300 kernel/kthread.c:386
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
 </TASK>

Allocated by task 4549:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_alloc_info+0x1f/0x30 mm/kasan/generic.c:505
 __kasan_slab_alloc+0x6c/0x80 mm/kasan/common.c:333
 kasan_slab_alloc include/linux/kasan.h:202 [inline]
 slab_post_alloc_hook+0x53/0x2c0 mm/slab.h:768
 slab_alloc_node mm/slub.c:3421 [inline]
 slab_alloc mm/slub.c:3429 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3436 [inline]
 kmem_cache_alloc+0x175/0x2c0 mm/slub.c:3445
 getname_flags+0xba/0x520 fs/namei.c:139
 getname+0x19/0x20 fs/namei.c:218
 do_sys_openat2+0xe0/0x870 fs/open.c:1335
 do_sys_open fs/open.c:1357 [inline]
 __do_sys_openat fs/open.c:1373 [inline]
 __se_sys_openat fs/open.c:1368 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1368
 x64_sys_call+0x6bf/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:258
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Freed by task 4549:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0x131/0x180 mm/kasan/common.c:241
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:249
 kasan_slab_free include/linux/kasan.h:178 [inline]
 slab_free_hook mm/slub.c:1745 [inline]
 slab_free_freelist_hook mm/slub.c:1771 [inline]
 slab_free mm/slub.c:3684 [inline]
 kmem_cache_free+0x291/0x510 mm/slub.c:3706
 putname+0xfa/0x150 fs/namei.c:272
 do_sys_openat2+0x21b/0x870 fs/open.c:1350
 do_sys_open fs/open.c:1357 [inline]
 __do_sys_openat fs/open.c:1373 [inline]
 __se_sys_openat fs/open.c:1368 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1368
 x64_sys_call+0x6bf/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:258
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

The buggy address belongs to the object at ffff8881168b2200
 which belongs to the cache names_cache of size 4096
The buggy address is located 704 bytes inside of
 4096-byte region [ffff8881168b2200, ffff8881168b3200)

The buggy address belongs to the physical page:
page:ffffea00045a2c00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1168b0
head:ffffea00045a2c00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head|zone=1)
raw: 4000000000010200 0000000000000000 dead000000000122 ffff8881002b3b00
raw: 0000000000000000 0000000000070007 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 4549, tgid 4549 (udevd), ts 537796639500, free_ts 537792829300
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x213/0x220 mm/page_alloc.c:2590
 prep_new_page+0x1b/0x110 mm/page_alloc.c:2597
 get_page_from_freelist+0x27ea/0x2870 mm/page_alloc.c:4425
 __alloc_pages+0x3a1/0x780 mm/page_alloc.c:5714
 alloc_slab_page+0x6c/0xf0
 allocate_slab mm/slub.c:1962 [inline]
 new_slab+0x90/0x3e0 mm/slub.c:2015
 ___slab_alloc+0x6f9/0xb80 mm/slub.c:3203
 __slab_alloc+0x5d/0xa0 mm/slub.c:3302
 slab_alloc_node mm/slub.c:3387 [inline]
 slab_alloc mm/slub.c:3429 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3436 [inline]
 kmem_cache_alloc+0x1b9/0x2c0 mm/slub.c:3445
 getname_flags+0xba/0x520 fs/namei.c:139
 vfs_fstatat fs/stat.c:266 [inline]
 __do_sys_newfstatat fs/stat.c:437 [inline]
 __se_sys_newfstatat+0xe2/0x7b0 fs/stat.c:431
 __x64_sys_newfstatat+0x9b/0xb0 fs/stat.c:431
 x64_sys_call+0x6e2/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:263
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1498 [inline]
 free_pcp_prepare mm/page_alloc.c:1572 [inline]
 free_unref_page_prepare+0x83d/0x850 mm/page_alloc.c:3498
 free_unref_page+0xb2/0x5c0 mm/page_alloc.c:3594
 free_the_page mm/page_alloc.c:798 [inline]
 __free_pages+0x61/0xf0 mm/page_alloc.c:5803
 __free_slab+0xce/0x1a0 mm/slub.c:2039
 free_slab mm/slub.c:2054 [inline]
 discard_slab+0x29/0x40 mm/slub.c:2060
 __slab_free+0x205/0x280 mm/slub.c:3597
 do_slab_free mm/slub.c:3638 [inline]
 ___cache_free+0xc6/0xd0 mm/slub.c:3691
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0xc5/0x140 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x15a/0x180 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x24/0x80 mm/kasan/common.c:310
 kasan_slab_alloc include/linux/kasan.h:202 [inline]
 slab_post_alloc_hook+0x53/0x2c0 mm/slab.h:768
 slab_alloc_node mm/slub.c:3421 [inline]
 slab_alloc mm/slub.c:3429 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3436 [inline]
 kmem_cache_alloc+0x175/0x2c0 mm/slub.c:3445
 getname_flags+0xba/0x520 fs/namei.c:139
 getname+0x19/0x20 fs/namei.c:218
 do_sys_openat2+0xe0/0x870 fs/open.c:1335
 do_sys_open fs/open.c:1357 [inline]
 __do_sys_openat fs/open.c:1373 [inline]
 __se_sys_openat fs/open.c:1368 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1368

Memory state around the buggy address:
 ffff8881168b2380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881168b2400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881168b2480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                           ^
 ffff8881168b2500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881168b2580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
device bridge_slave_1 left promiscuous mode
bridge0: port 2(bridge_slave_1) entered disabled state
device bridge_slave_0 left promiscuous mode
bridge0: port 1(bridge_slave_0) entered disabled state
device veth1_macvtap left promiscuous mode
device veth0_vlan left promiscuous mode
device bridge_slave_1 left promiscuous mode
bridge0: port 2(bridge_slave_1) entered disabled state
device bridge_slave_0 left promiscuous mode
bridge0: port 1(bridge_slave_0) entered disabled state
device bridge_slave_1 left promiscuous mode
bridge0: port 2(bridge_slave_1) entered disabled state
device bridge_slave_0 left promiscuous mode
bridge0: port 1(bridge_slave_0) entered disabled state
device bridge_slave_1 left promiscuous mode
bridge0: port 2(bridge_slave_1) entered disabled state
device bridge_slave_0 left promiscuous mode
bridge0: port 1(bridge_slave_0) entered disabled state
device bridge_slave_1 left promiscuous mode
bridge0: port 2(bridge_slave_1) entered disabled state
device bridge_slave_0 left promiscuous mode
bridge0: port 1(bridge_slave_0) entered disabled state
device veth1_macvtap left promiscuous mode
device veth0_vlan left promiscuous mode
device veth1_macvtap left promiscuous mode
device veth1_macvtap left promiscuous mode
device veth0_vlan left promiscuous mode
device veth1_macvtap left promiscuous mode
device veth0_vlan left promiscuous mode

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/10/18 20:01 android14-6.1 299cc91948f1 666f77ed .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in detach_if_pending
* Struck through repros no longer work on HEAD.