================================================================== 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 ffff888131e31f08 by task syz.0.2027/6492 CPU: 1 PID: 6492 Comm: syz.0.2027 Not tainted 6.1.118-syzkaller-00081-g616d7c64fd84 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/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:4300 [inline] xdp_do_redirect_frame+0x275/0x800 net/core/filter.c:4358 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:3665 __sys_bpf+0x59f/0x7f0 kernel/bpf/syscall.c:5020 __do_sys_bpf kernel/bpf/syscall.c:5106 [inline] __se_sys_bpf kernel/bpf/syscall.c:5104 [inline] __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5104 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:0x7fb63bb85d29 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:00007fb63c964038 EFLAGS: 00000246 ORIG_RAX: 0000000000000141 RAX: ffffffffffffffda RBX: 00007fb63bd75fa0 RCX: 00007fb63bb85d29 RDX: 0000000000000050 RSI: 00000000200000c0 RDI: 000000000000000a RBP: 00007fb63bc01b08 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fb63bd75fa0 R15: 00007fff96f324f8 Allocated by task 6328: 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:3431 [inline] __kmem_cache_alloc_lru mm/slub.c:3438 [inline] kmem_cache_alloc+0x175/0x320 mm/slub.c:3447 kmem_cache_zalloc include/linux/slab.h:683 [inline] __kernfs_new_node+0xdb/0x700 fs/kernfs/dir.c:614 kernfs_new_node+0x130/0x230 fs/kernfs/dir.c:690 __kernfs_create_file+0x4a/0x270 fs/kernfs/file.c:1049 sysfs_add_file_mode_ns+0x1c8/0x270 fs/sysfs/file.c:294 create_files fs/sysfs/group.c:64 [inline] internal_create_group+0x545/0xed0 fs/sysfs/group.c:148 internal_create_groups fs/sysfs/group.c:188 [inline] sysfs_create_groups+0x5b/0x130 fs/sysfs/group.c:214 device_add_groups drivers/base/core.c:2752 [inline] device_add_attrs+0x195/0x5f0 drivers/base/core.c:2911 device_add+0x5f7/0xf10 drivers/base/core.c:3648 netdev_register_kobject+0x177/0x320 net/core/net-sysfs.c:2009 register_netdevice+0xe43/0x1490 net/core/dev.c:10123 register_netdev+0x3c/0x50 net/core/dev.c:10249 sit_init_net+0x244/0x500 net/ipv6/sit.c:1860 ops_init+0x1cd/0x480 net/core/net_namespace.c:138 setup_net+0x4ca/0xd60 net/core/net_namespace.c:335 copy_net_ns+0x35f/0x5b0 net/core/net_namespace.c:481 create_new_namespaces+0x416/0x670 kernel/nsproxy.c:110 copy_namespaces+0x1d1/0x220 kernel/nsproxy.c:178 copy_process+0x12e2/0x3530 kernel/fork.c:2372 kernel_clone+0x229/0x890 kernel/fork.c:2785 __do_sys_clone kernel/fork.c:2928 [inline] __se_sys_clone kernel/fork.c:2912 [inline] __x64_sys_clone+0x231/0x280 kernel/fork.c:2912 x64_sys_call+0x1b0/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:57 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 570: 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:3686 [inline] kmem_cache_free+0x291/0x560 mm/slub.c:3711 kernfs_put+0x392/0x520 fs/kernfs/dir.c:568 kernfs_remove_by_name_ns+0xf4/0x160 fs/kernfs/dir.c:1667 kernfs_remove_by_name include/linux/kernfs.h:635 [inline] remove_files fs/sysfs/group.c:28 [inline] sysfs_remove_group+0x10c/0x2a0 fs/sysfs/group.c:288 sysfs_remove_groups+0x56/0xb0 fs/sysfs/group.c:312 device_remove_groups drivers/base/core.c:2759 [inline] device_remove_attrs+0x1d8/0x290 drivers/base/core.c:2973 device_del+0x65b/0xe90 drivers/base/core.c:3884 netdev_unregister_kobject+0x18b/0x260 net/core/net-sysfs.c:1981 unregister_netdevice_many+0x1227/0x1730 net/core/dev.c:10933 sit_exit_batch_net+0x623/0x670 net/ipv6/sit.c:1887 ops_exit_list net/core/net_namespace.c:177 [inline] cleanup_net+0x6c9/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:295 The buggy address belongs to the object at ffff888131e31ed8 which belongs to the cache kernfs_node_cache of size 136 The buggy address is located 48 bytes inside of 136-byte region [ffff888131e31ed8, ffff888131e31f60) The buggy address belongs to the physical page: page:ffffea0004c78c40 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x131e31 flags: 0x4000000000000200(slab|zone=1) raw: 4000000000000200 0000000000000000 dead000000000122 ffff8881002aa600 raw: 0000000000000000 0000000000140014 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 6328, tgid 6327 (syz.2.1977), ts 258528708829, free_ts 258496374703 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+0x2f41/0x2fc0 mm/page_alloc.c:4462 __alloc_pages+0x234/0x610 mm/page_alloc.c:5759 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:3431 [inline] __kmem_cache_alloc_lru mm/slub.c:3438 [inline] kmem_cache_alloc+0x1be/0x320 mm/slub.c:3447 kmem_cache_zalloc include/linux/slab.h:683 [inline] __kernfs_new_node+0xdb/0x700 fs/kernfs/dir.c:614 kernfs_new_node+0x130/0x230 fs/kernfs/dir.c:690 __kernfs_create_file+0x4a/0x270 fs/kernfs/file.c:1049 sysfs_add_file_mode_ns+0x1c8/0x270 fs/sysfs/file.c:294 create_files fs/sysfs/group.c:64 [inline] internal_create_group+0x545/0xed0 fs/sysfs/group.c:148 internal_create_groups fs/sysfs/group.c:188 [inline] sysfs_create_groups+0x5b/0x130 fs/sysfs/group.c:214 device_add_groups drivers/base/core.c:2752 [inline] device_add_attrs+0xe1/0x5f0 drivers/base/core.c:2900 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:3511 free_unref_page_list+0xf1/0x7b0 mm/page_alloc.c:3659 release_pages+0xf7f/0xfe0 mm/swap.c:1063 free_pages_and_swap_cache+0x8a/0xa0 mm/swap_state.c:315 tlb_batch_pages_flush mm/mmu_gather.c:59 [inline] tlb_flush_mmu_free mm/mmu_gather.c:254 [inline] tlb_flush_mmu mm/mmu_gather.c:261 [inline] tlb_finish_mmu+0x1e0/0x3f0 mm/mmu_gather.c:361 exit_mmap+0x460/0xbe0 mm/mmap.c:3348 __mmput+0x95/0x310 kernel/fork.c:1299 mmput+0x56/0x170 kernel/fork.c:1322 copy_process+0x2242/0x3530 kernel/fork.c:2637 kernel_clone+0x229/0x890 kernel/fork.c:2785 __do_sys_clone kernel/fork.c:2928 [inline] __se_sys_clone kernel/fork.c:2912 [inline] __x64_sys_clone+0x231/0x280 kernel/fork.c:2912 x64_sys_call+0x1b0/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:57 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 Memory state around the buggy address: ffff888131e31e00: fc fc fa fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888131e31e80: fb fb fb fc fc fc fc fc fc fc fc fa fb fb fb fb >ffff888131e31f00: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ^ ffff888131e31f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888131e32000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ================================================================== general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] CPU: 1 PID: 6492 Comm: syz.0.2027 Tainted: G B 6.1.118-syzkaller-00081-g616d7c64fd84 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 RIP: 0010:bq_flush_to_queue+0x47/0x6e0 kernel/bpf/cpumap.c:713 Code: df e8 fd 6e dd ff 49 8d 5f 50 48 89 d8 48 c1 e8 03 42 80 3c 20 00 74 08 48 89 df e8 23 e3 24 00 48 8b 1b 48 89 d8 48 c1 e8 03 <42> 0f b6 04 20 84 c0 0f 85 cd 04 00 00 48 89 5d 80 44 8b 33 4d 8d RSP: 0018:ffffc9000ec775d8 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000080000 RDX: ffffc900012d9000 RSI: 0000000000032298 RDI: 0000000000032299 RBP: ffffc9000ec77668 R08: ffffffff81981688 R09: 0000000000000003 R10: ffffffffffffffff R11: dffffc0000000001 R12: dffffc0000000000 R13: ffff8881f6f34440 R14: ffff8881f6f34440 R15: ffff8881f6f00000 FS: 00007fb63c9646c0(0000) GS:ffff8881f6f00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffd88f0000 CR3: 00000001180f1000 CR4: 00000000003506a0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600 Call Trace: __cpu_map_flush+0xab/0x130 kernel/bpf/cpumap.c:804 xdp_do_flush+0x13/0x20 net/core/filter.c:4185 xdp_test_run_batch net/bpf/test_run.c:332 [inline] bpf_test_run_xdp_live+0x167d/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:3665 __sys_bpf+0x59f/0x7f0 kernel/bpf/syscall.c:5020 __do_sys_bpf kernel/bpf/syscall.c:5106 [inline] __se_sys_bpf kernel/bpf/syscall.c:5104 [inline] __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5104 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:0x7fb63bb85d29 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:00007fb63c964038 EFLAGS: 00000246 ORIG_RAX: 0000000000000141 RAX: ffffffffffffffda RBX: 00007fb63bd75fa0 RCX: 00007fb63bb85d29 RDX: 0000000000000050 RSI: 00000000200000c0 RDI: 000000000000000a RBP: 00007fb63bc01b08 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fb63bd75fa0 R15: 00007fff96f324f8 Modules linked in: ---[ end trace 0000000000000000 ]--- RIP: 0010:bq_flush_to_queue+0x47/0x6e0 kernel/bpf/cpumap.c:713 Code: df e8 fd 6e dd ff 49 8d 5f 50 48 89 d8 48 c1 e8 03 42 80 3c 20 00 74 08 48 89 df e8 23 e3 24 00 48 8b 1b 48 89 d8 48 c1 e8 03 <42> 0f b6 04 20 84 c0 0f 85 cd 04 00 00 48 89 5d 80 44 8b 33 4d 8d RSP: 0018:ffffc9000ec775d8 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000080000 RDX: ffffc900012d9000 RSI: 0000000000032298 RDI: 0000000000032299 RBP: ffffc9000ec77668 R08: ffffffff81981688 R09: 0000000000000003 R10: ffffffffffffffff R11: dffffc0000000001 R12: dffffc0000000000 R13: ffff8881f6f34440 R14: ffff8881f6f34440 R15: ffff8881f6f00000 FS: 00007fb63c9646c0(0000) GS:ffff8881f6f00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffd88f0000 CR3: 00000001180f1000 CR4: 00000000003506a0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600 ---------------- Code disassembly (best guess), 1 bytes skipped: 0: e8 fd 6e dd ff call 0xffdd6f02 5: 49 8d 5f 50 lea 0x50(%r15),%rbx 9: 48 89 d8 mov %rbx,%rax c: 48 c1 e8 03 shr $0x3,%rax 10: 42 80 3c 20 00 cmpb $0x0,(%rax,%r12,1) 15: 74 08 je 0x1f 17: 48 89 df mov %rbx,%rdi 1a: e8 23 e3 24 00 call 0x24e342 1f: 48 8b 1b mov (%rbx),%rbx 22: 48 89 d8 mov %rbx,%rax 25: 48 c1 e8 03 shr $0x3,%rax * 29: 42 0f b6 04 20 movzbl (%rax,%r12,1),%eax <-- trapping instruction 2e: 84 c0 test %al,%al 30: 0f 85 cd 04 00 00 jne 0x503 36: 48 89 5d 80 mov %rbx,-0x80(%rbp) 3a: 44 8b 33 mov (%rbx),%r14d 3d: 4d rex.WRB 3e: 8d .byte 0x8d