================================================================== BUG: KASAN: use-after-free in dev_map_enqueue+0x3c/0x340 kernel/bpf/devmap.c:532 Read of size 8 at addr ffff88807c416200 by task syz.4.999/7583 CPU: 0 PID: 7583 Comm: syz.4.999 Not tainted 6.1.115-syzkaller #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+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 dev_map_enqueue+0x3c/0x340 kernel/bpf/devmap.c:532 __xdp_do_redirect_frame net/core/filter.c:4296 [inline] xdp_do_redirect_frame+0x323/0x660 net/core/filter.c:4358 xdp_test_run_batch net/bpf/test_run.c:314 [inline] bpf_test_run_xdp_live+0xbf4/0x1ea0 net/bpf/test_run.c:362 bpf_prog_test_run_xdp+0x7d1/0x1130 net/bpf/test_run.c:1393 bpf_prog_test_run+0x32f/0x3a0 kernel/bpf/syscall.c:3685 __sys_bpf+0x3eb/0x6c0 kernel/bpf/syscall.c:5038 __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 RIP: 0033:0x7fee5217e719 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:00007fee52fbc038 EFLAGS: 00000246 ORIG_RAX: 0000000000000141 RAX: ffffffffffffffda RBX: 00007fee52335f80 RCX: 00007fee5217e719 RDX: 0000000000000050 RSI: 00000000200000c0 RDI: 000000000000000a RBP: 00007fee521f139e R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fee52335f80 R15: 00007fff1799a328 Allocated by task 6982: 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:936 [inline] __kmalloc_node+0xb3/0x230 mm/slab_common.c:943 kmalloc_node include/linux/slab.h:583 [inline] bpf_map_kmalloc_node+0xce/0x1c0 kernel/bpf/syscall.c:452 __dev_map_alloc_node+0x56/0x4d0 kernel/bpf/devmap.c:851 __dev_map_hash_update_elem kernel/bpf/devmap.c:961 [inline] dev_map_hash_update_elem+0x322/0x7a0 kernel/bpf/devmap.c:995 bpf_map_update_value+0x5cf/0x6f0 kernel/bpf/syscall.c:226 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 call_rcu+0x163/0xa10 kernel/rcu/tree.c:2845 nf_unregister_net_hooks+0xcc/0x130 net/netfilter/core.c:601 nf_ct_netns_put+0x36c/0x510 nf_conncount_destroy+0x42/0x150 net/netfilter/nf_conncount.c:590 ovs_ct_limit_exit net/openvswitch/conntrack.c:1919 [inline] ovs_ct_exit+0x95/0x200 net/openvswitch/conntrack.c:2322 ovs_exit_net+0xea/0x7c0 net/openvswitch/datapath.c:2649 ops_exit_list net/core/net_namespace.c:172 [inline] cleanup_net+0x6ce/0xb60 net/core/net_namespace.c:604 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 ffff88807c416200 which belongs to the cache kmalloc-cg-96 of size 96 The buggy address is located 0 bytes inside of 96-byte region [ffff88807c416200, ffff88807c416260) The buggy address belongs to the physical page: page:ffffea0001f10580 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88807c416c00 pfn:0x7c416 memcg:ffff8880749af801 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffffea00016958c0 dead000000000004 ffff888017c428c0 raw: ffff88807c416c00 0000000080200004 00000001ffffffff ffff8880749af801 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 4245, tgid 4245 (syz-executor), ts 65435583798, free_ts 65435344569 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:4290 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5558 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:935 [inline] __kmalloc_node+0xa2/0x230 mm/slab_common.c:943 kmalloc_node include/linux/slab.h:583 [inline] kvmalloc_node+0x6e/0x180 mm/util.c:581 kvmalloc include/linux/slab.h:710 [inline] kvzalloc include/linux/slab.h:718 [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_mangle_table_init+0x3e/0x60 net/ipv4/netfilter/iptable_mangle.c:91 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:3369 free_unref_page+0x33/0x3e0 mm/page_alloc.c:3464 __vunmap+0x834/0x9a0 mm/vmalloc.c:2717 copy_entries_to_user net/ipv4/netfilter/ip_tables.c:868 [inline] get_entries net/ipv4/netfilter/ip_tables.c:1024 [inline] do_ipt_get_ctl+0x11d8/0x1890 net/ipv4/netfilter/ip_tables.c:1670 nf_getsockopt+0x28e/0x2b0 net/netfilter/nf_sockopt.c:116 ip_getsockopt+0x21a/0x2d0 net/ipv4/ip_sockglue.c:1826 tcp_getsockopt+0x15c/0x1c0 net/ipv4/tcp.c:4450 __sys_getsockopt+0x2b2/0x5d0 net/socket.c:2332 __do_sys_getsockopt net/socket.c:2347 [inline] __se_sys_getsockopt net/socket.c:2344 [inline] __x64_sys_getsockopt+0xb1/0xc0 net/socket.c:2344 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: ffff88807c416100: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ffff88807c416180: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc >ffff88807c416200: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ^ ffff88807c416280: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ffff88807c416300: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ==================================================================