================================================================== BUG: KASAN: use-after-free in bq_enqueue kernel/bpf/cpumap.c:749 [inline] BUG: KASAN: use-after-free in cpu_map_enqueue+0xb6/0x370 kernel/bpf/cpumap.c:775 Read of size 8 at addr ffff88807ea25608 by task syz.4.1397/8111 CPU: 0 PID: 8111 Comm: syz.4.1397 Not tainted 6.1.102-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024 Call Trace: __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 bq_enqueue kernel/bpf/cpumap.c:749 [inline] cpu_map_enqueue+0xb6/0x370 kernel/bpf/cpumap.c:775 __xdp_do_redirect_frame net/core/filter.c:4291 [inline] xdp_do_redirect+0x666/0xb90 net/core/filter.c:4335 tun_xdp_act+0xdc/0xd50 drivers/net/tun.c:1625 tun_build_skb drivers/net/tun.c:1715 [inline] tun_get_user+0x3118/0x42d0 drivers/net/tun.c:1818 tun_chr_write_iter+0x10c/0x1f0 drivers/net/tun.c:2044 call_write_iter include/linux/fs.h:2265 [inline] new_sync_write fs/read_write.c:491 [inline] vfs_write+0x857/0xbc0 fs/read_write.c:584 ksys_write+0x19c/0x2c0 fs/read_write.c:637 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:0x7fdd78575e1f Code: 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 29 8c 02 00 48 8b 54 24 18 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 31 44 89 c7 48 89 44 24 08 e8 7c 8c 02 00 48 RSP: 002b:00007fdd7925f010 EFLAGS: 00000293 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007fdd78705f80 RCX: 00007fdd78575e1f RDX: 0000000000000106 RSI: 0000000020000900 RDI: 00000000000000c8 RBP: 00007fdd785e48e6 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000106 R11: 0000000000000293 R12: 0000000000000000 R13: 000000000000000b R14: 00007fdd78705f80 R15: 00007ffc89a1b098 Allocated by task 5406: 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_node+0xb3/0x230 mm/slab_common.c:962 kmalloc_node include/linux/slab.h:582 [inline] bpf_map_kmalloc_node+0xce/0x1c0 kernel/bpf/syscall.c:452 __cpu_map_entry_alloc kernel/bpf/cpumap.c:445 [inline] cpu_map_update_elem+0x277/0xf60 kernel/bpf/cpumap.c:603 map_update_elem+0x503/0x680 kernel/bpf/syscall.c:1463 __sys_bpf+0x337/0x6c0 kernel/bpf/syscall.c:5008 __do_sys_bpf kernel/bpf/syscall.c:5124 [inline] __se_sys_bpf kernel/bpf/syscall.c:5122 [inline] __x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:5122 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 Last potentially related work creation: kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:486 insert_work+0x54/0x3d0 kernel/workqueue.c:1361 __queue_work+0xb4b/0xf90 kernel/workqueue.c:1520 queue_work_on+0x14b/0x250 kernel/workqueue.c:1548 cpu_map_free+0xd7/0x1b0 kernel/bpf/cpumap.c:641 process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439 kthread+0x28d/0x320 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 Second to last potentially related work creation: kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:486 call_rcu+0x163/0xa10 kernel/rcu/tree.c:2844 __cpu_map_entry_replace+0x74/0x170 kernel/bpf/cpumap.c:556 cpu_map_free+0xd7/0x1b0 kernel/bpf/cpumap.c:641 process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439 kthread+0x28d/0x320 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 The buggy address belongs to the object at ffff88807ea25600 which belongs to the cache kmalloc-cg-256 of size 256 The buggy address is located 8 bytes inside of 256-byte region [ffff88807ea25600, ffff88807ea25700) The buggy address belongs to the physical page: page:ffffea0001fa8900 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7ea24 head:ffffea0001fa8900 order:1 compound_mapcount:0 compound_pincount:0 memcg:ffff888058e7cb01 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 ffffea0004ff9800 dead000000000003 ffff888012842c80 raw: 0000000000000000 0000000080100010 00000001ffffffff ffff888058e7cb01 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 1, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 3651, tgid 3651 (syz-executor), ts 65909969872, free_ts 65798132867 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2517 prep_new_page mm/page_alloc.c:2524 [inline] get_page_from_freelist+0x322e/0x33b0 mm/page_alloc.c:4283 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5551 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+0xc20/0x1270 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_node+0xa2/0x230 mm/slab_common.c:962 kmalloc_node include/linux/slab.h:582 [inline] kvmalloc_node+0x6e/0x180 mm/util.c:581 kvmalloc include/linux/slab.h:709 [inline] kvzalloc include/linux/slab.h:717 [inline] allocate_hook_entries_size net/netfilter/core.c:61 [inline] nf_hook_entries_grow+0x331/0x760 net/netfilter/core.c:128 __nf_register_net_hook+0x29c/0x930 net/netfilter/core.c:423 nf_register_net_hook+0xac/0x180 net/netfilter/core.c:566 nf_register_net_hooks+0x3d/0x1a0 net/netfilter/core.c:582 ipt_register_table+0x4ca/0x7a0 net/ipv4/netfilter/ip_tables.c:1783 iptable_security_table_init+0x3e/0x60 net/ipv4/netfilter/iptable_security.c:46 xt_find_table_lock+0x2cc/0x3a0 net/netfilter/x_tables.c:1259 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1444 [inline] free_pcp_prepare mm/page_alloc.c:1494 [inline] free_unref_page_prepare+0xf63/0x1120 mm/page_alloc.c:3362 free_unref_page+0x33/0x3e0 mm/page_alloc.c:3457 qlink_free mm/kasan/quarantine.c:168 [inline] qlist_free_all+0x76/0xe0 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x156/0x170 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+0x52/0x3a0 mm/slab.h:737 slab_alloc_node mm/slub.c:3398 [inline] __kmem_cache_alloc_node+0x137/0x260 mm/slub.c:3437 kmalloc_trace+0x26/0xe0 mm/slab_common.c:1045 kmalloc include/linux/slab.h:556 [inline] get_mountpoint+0x207/0x440 fs/namespace.c:794 lock_mount+0xba/0x2c0 fs/namespace.c:2300 do_loopback+0x2b7/0x510 fs/namespace.c:2436 do_mount fs/namespace.c:3394 [inline] __do_sys_mount fs/namespace.c:3602 [inline] __se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3579 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: ffff88807ea25500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88807ea25580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88807ea25600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88807ea25680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88807ea25700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================