================================================================== BUG: KASAN: use-after-free in bq_enqueue kernel/bpf/cpumap.c:749 [inline] BUG: KASAN: use-after-free in cpu_map_enqueue+0xb4/0x370 kernel/bpf/cpumap.c:775 Read of size 8 at addr ffff888131d81608 by task syz.3.3436/11828 CPU: 0 PID: 11828 Comm: syz.3.3436 Tainted: G W 6.1.99-syzkaller-00091-g110595418159 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024 Call Trace: __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_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:351 bq_enqueue kernel/bpf/cpumap.c:749 [inline] cpu_map_enqueue+0xb4/0x370 kernel/bpf/cpumap.c:775 __xdp_do_redirect_frame net/core/filter.c:4291 [inline] xdp_do_redirect_frame+0x275/0x800 net/core/filter.c:4349 xdp_test_run_batch net/bpf/test_run.c:314 [inline] bpf_test_run_xdp_live+0xc30/0x1f70 net/bpf/test_run.c:362 bpf_prog_test_run_xdp+0x7d1/0x1130 net/bpf/test_run.c:1393 bpf_prog_test_run+0x3b0/0x630 kernel/bpf/syscall.c:3650 __sys_bpf+0x59f/0x7f0 kernel/bpf/syscall.c:5005 __do_sys_bpf kernel/bpf/syscall.c:5091 [inline] __se_sys_bpf kernel/bpf/syscall.c:5089 [inline] __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5089 x64_sys_call+0x87f/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:322 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 RIP: 0033:0x7f51bd57dff9 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f51be45f038 EFLAGS: 00000246 ORIG_RAX: 0000000000000141 RAX: ffffffffffffffda RBX: 00007f51bd735f80 RCX: 00007f51bd57dff9 RDX: 0000000000000050 RSI: 00000000200000c0 RDI: 000000000000000a RBP: 00007f51bd5f0296 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f51bd735f80 R15: 00007fffd88c4dd8 Allocated by task 11174: 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_kmalloc mm/kasan/common.c:379 [inline] __kasan_kmalloc+0x9c/0xb0 mm/kasan/common.c:388 kasan_kmalloc include/linux/kasan.h:212 [inline] kmalloc_trace+0x44/0xa0 mm/slab_common.c:1052 kmalloc include/linux/slab.h:556 [inline] kzalloc include/linux/slab.h:692 [inline] kernfs_fop_open+0x350/0xb10 fs/kernfs/file.c:666 do_dentry_open+0x891/0x1250 fs/open.c:884 vfs_open+0x73/0x80 fs/open.c:1015 do_open fs/namei.c:3627 [inline] path_openat+0x2532/0x2d60 fs/namei.c:3784 do_filp_open+0x230/0x480 fs/namei.c:3811 do_sys_openat2+0x151/0x870 fs/open.c:1341 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 11174: 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+0x218/0x3b0 mm/slub.c:3697 kfree+0x7a/0xf0 mm/slab_common.c:1009 kernfs_fop_release+0x28c/0x310 fs/kernfs/file.c:804 __fput+0x1e5/0x870 fs/file_table.c:320 ____fput+0x15/0x20 fs/file_table.c:348 task_work_run+0x24d/0x2e0 kernel/task_work.c:179 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop+0x94/0xa0 kernel/entry/common.c:177 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:210 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline] syscall_exit_to_user_mode+0x26/0x130 kernel/entry/common.c:303 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87 entry_SYSCALL_64_after_hwframe+0x68/0xd2 Last potentially related work creation: kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45 __kasan_record_aux_stack+0xb4/0xc0 mm/kasan/generic.c:486 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:496 kvfree_call_rcu+0x9f/0x800 kernel/rcu/tree.c:3444 ip_ma_put+0xea/0x130 net/ipv4/igmp.c:171 __ip_mc_dec_group+0x4b2/0x590 net/ipv4/igmp.c:1697 ip_mc_dec_group include/linux/igmp.h:135 [inline] ip_mc_down+0x1a4/0x240 net/ipv4/igmp.c:1752 inetdev_event+0x2ce/0x1110 net/ipv4/devinet.c:1588 notifier_call_chain kernel/notifier.c:87 [inline] raw_notifier_call_chain+0x8c/0xf0 kernel/notifier.c:455 call_netdevice_notifiers_info net/core/dev.c:1978 [inline] call_netdevice_notifiers_extack net/core/dev.c:2016 [inline] call_netdevice_notifiers net/core/dev.c:2030 [inline] dev_close_many+0x37c/0x530 net/core/dev.c:1578 unregister_netdevice_many+0x4d1/0x1740 net/core/dev.c:10864 unregister_netdevice_queue+0x2e6/0x350 net/core/dev.c:10821 unregister_netdevice include/linux/netdevice.h:3100 [inline] __tun_detach+0xd14/0x1510 drivers/net/tun.c:685 tun_detach drivers/net/tun.c:701 [inline] tun_chr_close+0x92/0x140 drivers/net/tun.c:3489 __fput+0x1e5/0x870 fs/file_table.c:320 ____fput+0x15/0x20 fs/file_table.c:348 task_work_run+0x24d/0x2e0 kernel/task_work.c:179 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop+0x94/0xa0 kernel/entry/common.c:177 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:210 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline] syscall_exit_to_user_mode+0x26/0x130 kernel/entry/common.c:303 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87 entry_SYSCALL_64_after_hwframe+0x68/0xd2 Second to last potentially related work creation: kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45 __kasan_record_aux_stack+0xb4/0xc0 mm/kasan/generic.c:486 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:496 insert_work+0x56/0x310 kernel/workqueue.c:1368 __queue_work+0x9b6/0xd70 kernel/workqueue.c:1527 queue_work_on+0x105/0x170 kernel/workqueue.c:1555 queue_work include/linux/workqueue.h:510 [inline] schedule_work include/linux/workqueue.h:571 [inline] __cpu_map_entry_replace kernel/bpf/cpumap.c:558 [inline] cpu_map_free+0x1e7/0x2c0 kernel/bpf/cpumap.c:641 bpf_map_free_deferred+0xf7/0x1b0 kernel/bpf/syscall.c:622 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 The buggy address belongs to the object at ffff888131d81600 which belongs to the cache kmalloc-192 of size 192 The buggy address is located 8 bytes inside of 192-byte region [ffff888131d81600, ffff888131d816c0) The buggy address belongs to the physical page: page:ffffea0004c76040 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x131d81 flags: 0x4000000000000200(slab|zone=1) raw: 4000000000000200 dead000000000100 dead000000000122 ffff888100042c00 raw: 0000000000000000 0000000000100010 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 103, tgid 103 (udevd), ts 50347347801, free_ts 50339693999 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] __kmem_cache_alloc_node+0x1af/0x250 mm/slub.c:3460 kmalloc_trace+0x2a/0xa0 mm/slab_common.c:1047 kmalloc include/linux/slab.h:556 [inline] kzalloc include/linux/slab.h:692 [inline] kernfs_fop_open+0x350/0xb10 fs/kernfs/file.c:666 do_dentry_open+0x891/0x1250 fs/open.c:884 vfs_open+0x73/0x80 fs/open.c:1015 do_open fs/namei.c:3627 [inline] path_openat+0x2532/0x2d60 fs/namei.c:3784 do_filp_open+0x230/0x480 fs/namei.c:3811 do_sys_openat2+0x151/0x870 fs/open.c:1341 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 mm/slub.c:2060 [inline] __unfreeze_partials+0x165/0x1a0 mm/slub.c:2609 put_cpu_partial+0xa9/0x100 mm/slub.c:2685 __slab_free+0x1c8/0x280 mm/slub.c:3561 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 user_path_at_empty+0x2d/0x1a0 fs/namei.c:2905 do_readlinkat+0x114/0x3a0 fs/stat.c:468 Memory state around the buggy address: ffff888131d81500: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888131d81580: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc >ffff888131d81600: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888131d81680: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff888131d81700: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== general protection fault, probably for non-canonical address 0xe0c02d2f1edc057f: 0000 [#1] PREEMPT SMP KASAN KASAN: maybe wild-memory-access in range [0x06018978f6e02bf8-0x06018978f6e02bff] CPU: 0 PID: 11828 Comm: syz.3.3436 Tainted: G B W 6.1.99-syzkaller-00091-g110595418159 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024 RIP: 0010:bq_enqueue kernel/bpf/cpumap.c:751 [inline] RIP: 0010:cpu_map_enqueue+0x113/0x370 kernel/bpf/cpumap.c:775 Code: e8 03 42 80 3c 30 00 74 08 48 89 df e8 16 d4 24 00 4c 8b 23 4f 8d 74 3c 58 4d 89 f5 49 c1 ed 03 48 b8 00 00 00 00 00 fc ff df <41> 0f b6 44 05 00 84 c0 0f 85 a8 01 00 00 4d 01 fc 41 8b 1e bf 08 RSP: 0018:ffffc900088bf600 EFLAGS: 00010203 RAX: dffffc0000000000 RBX: ffffffff86745880 RCX: 0000000000040000 RDX: ffffc9000a386000 RSI: 0000000000037f2e RDI: 0000000000037f2f RBP: ffffc900088bf638 R08: ffffffff81980e9e R09: fffffbfff0f6dafd R10: 0000000000000000 R11: dffffc0000000001 R12: ffff8881f6e00000 R13: 00c0312f1edc057f R14: 06018978f6e02bfe R15: 060200f700002ba6 FS: 00007f51be45f6c0(0000) GS:ffff8881f6e00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 000000012911c000 CR4: 00000000003506b0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600 Call Trace: __xdp_do_redirect_frame net/core/filter.c:4291 [inline] xdp_do_redirect_frame+0x275/0x800 net/core/filter.c:4349 xdp_test_run_batch net/bpf/test_run.c:314 [inline] bpf_test_run_xdp_live+0xc30/0x1f70 net/bpf/test_run.c:362 bpf_prog_test_run_xdp+0x7d1/0x1130 net/bpf/test_run.c:1393 bpf_prog_test_run+0x3b0/0x630 kernel/bpf/syscall.c:3650 __sys_bpf+0x59f/0x7f0 kernel/bpf/syscall.c:5005 __do_sys_bpf kernel/bpf/syscall.c:5091 [inline] __se_sys_bpf kernel/bpf/syscall.c:5089 [inline] __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5089 x64_sys_call+0x87f/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:322 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 RIP: 0033:0x7f51bd57dff9 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f51be45f038 EFLAGS: 00000246 ORIG_RAX: 0000000000000141 RAX: ffffffffffffffda RBX: 00007f51bd735f80 RCX: 00007f51bd57dff9 RDX: 0000000000000050 RSI: 00000000200000c0 RDI: 000000000000000a RBP: 00007f51bd5f0296 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f51bd735f80 R15: 00007fffd88c4dd8 Modules linked in: ---[ end trace 0000000000000000 ]--- RIP: 0010:bq_enqueue kernel/bpf/cpumap.c:751 [inline] RIP: 0010:cpu_map_enqueue+0x113/0x370 kernel/bpf/cpumap.c:775 Code: e8 03 42 80 3c 30 00 74 08 48 89 df e8 16 d4 24 00 4c 8b 23 4f 8d 74 3c 58 4d 89 f5 49 c1 ed 03 48 b8 00 00 00 00 00 fc ff df <41> 0f b6 44 05 00 84 c0 0f 85 a8 01 00 00 4d 01 fc 41 8b 1e bf 08 RSP: 0018:ffffc900088bf600 EFLAGS: 00010203 RAX: dffffc0000000000 RBX: ffffffff86745880 RCX: 0000000000040000 RDX: ffffc9000a386000 RSI: 0000000000037f2e RDI: 0000000000037f2f RBP: ffffc900088bf638 R08: ffffffff81980e9e R09: fffffbfff0f6dafd R10: 0000000000000000 R11: dffffc0000000001 R12: ffff8881f6e00000 R13: 00c0312f1edc057f R14: 06018978f6e02bfe R15: 060200f700002ba6 FS: 00007f51be45f6c0(0000) GS:ffff8881f6e00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 000000012911c000 CR4: 00000000003506b0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600 ---------------- Code disassembly (best guess): 0: e8 03 42 80 3c call 0x3c804208 5: 30 00 xor %al,(%rax) 7: 74 08 je 0x11 9: 48 89 df mov %rbx,%rdi c: e8 16 d4 24 00 call 0x24d427 11: 4c 8b 23 mov (%rbx),%r12 14: 4f 8d 74 3c 58 lea 0x58(%r12,%r15,1),%r14 19: 4d 89 f5 mov %r14,%r13 1c: 49 c1 ed 03 shr $0x3,%r13 20: 48 b8 00 00 00 00 00 movabs $0xdffffc0000000000,%rax 27: fc ff df * 2a: 41 0f b6 44 05 00 movzbl 0x0(%r13,%rax,1),%eax <-- trapping instruction 30: 84 c0 test %al,%al 32: 0f 85 a8 01 00 00 jne 0x1e0 38: 4d 01 fc add %r15,%r12 3b: 41 8b 1e mov (%r14),%ebx 3e: bf .byte 0xbf 3f: 08 .byte 0x8