================================================================== BUG: KASAN: use-after-free in dev_map_generic_redirect+0xa8/0x59c kernel/bpf/devmap.c:668 Read of size 8 at addr ffff0000cd498a00 by task syz.7.1393/8681 CPU: 1 PID: 8681 Comm: syz.7.1393 Not tainted 6.1.129-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024 Call trace: dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165 __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:316 [inline] print_report+0x174/0x4c0 mm/kasan/report.c:427 kasan_report+0xd4/0x130 mm/kasan/report.c:531 __asan_report_load8_noabort+0x2c/0x38 mm/kasan/report_generic.c:351 dev_map_generic_redirect+0xa8/0x59c kernel/bpf/devmap.c:668 xdp_do_generic_redirect_map net/core/filter.c:4416 [inline] xdp_do_generic_redirect+0x3ec/0x6e4 net/core/filter.c:4475 do_xdp_generic+0x460/0x634 net/core/dev.c:4957 __netif_receive_skb_core+0x15d4/0x378c net/core/dev.c:5359 __netif_receive_skb_one_core net/core/dev.c:5536 [inline] __netif_receive_skb+0x114/0x400 net/core/dev.c:5652 process_backlog+0x410/0x784 net/core/dev.c:5980 __napi_poll+0xb4/0x3f0 net/core/dev.c:6547 napi_poll net/core/dev.c:6614 [inline] net_rx_action+0x5cc/0xd3c net/core/dev.c:6728 handle_softirqs+0x318/0xd58 kernel/softirq.c:578 __do_softirq+0x14/0x20 kernel/softirq.c:612 ____do_softirq+0x14/0x20 arch/arm64/kernel/irq.c:80 call_on_irq_stack+0x24/0x4c arch/arm64/kernel/entry.S:893 do_softirq_own_stack+0x20/0x2c arch/arm64/kernel/irq.c:85 do_softirq+0xf8/0x1ac kernel/softirq.c:479 __local_bh_enable_ip+0x298/0x470 kernel/softirq.c:403 local_bh_enable+0x28/0x34 include/linux/bottom_half.h:33 rcu_read_unlock_bh include/linux/rcupdate.h:861 [inline] __dev_queue_xmit+0x17f4/0x34d4 net/core/dev.c:4330 dev_queue_xmit include/linux/netdevice.h:3049 [inline] neigh_hh_output include/net/neighbour.h:528 [inline] neigh_output include/net/neighbour.h:542 [inline] ip_finish_output2+0xc9c/0x11f0 net/ipv4/ip_output.c:228 __ip_finish_output+0x1b0/0x458 ip_finish_output+0x40/0x268 net/ipv4/ip_output.c:316 NF_HOOK_COND include/linux/netfilter.h:291 [inline] ip_output+0x330/0x49c net/ipv4/ip_output.c:430 dst_output include/net/dst.h:444 [inline] ip_local_out net/ipv4/ip_output.c:126 [inline] __ip_queue_xmit+0xcd4/0x1730 net/ipv4/ip_output.c:532 ip_queue_xmit+0x5c/0x78 net/ipv4/ip_output.c:546 __tcp_transmit_skb+0x18ec/0x2ef4 net/ipv4/tcp_output.c:1405 tcp_transmit_skb net/ipv4/tcp_output.c:1423 [inline] tcp_connect+0x18ac/0x3c60 net/ipv4/tcp_output.c:3930 tcp_v4_connect+0xc7c/0x15cc net/ipv4/tcp_ipv4.c:333 tcp_v6_connect+0xaa8/0x1770 net/ipv6/tcp_ipv6.c:250 __inet_stream_connect+0x200/0xc70 net/ipv4/af_inet.c:668 inet_stream_connect+0x74/0xb0 net/ipv4/af_inet.c:739 __sys_connect_file net/socket.c:2011 [inline] __sys_connect+0x268/0x290 net/socket.c:2028 __do_sys_connect net/socket.c:2038 [inline] __se_sys_connect net/socket.c:2035 [inline] __arm64_sys_connect+0x7c/0x94 net/socket.c:2035 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2bc arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140 do_el0_svc+0x58/0x13c arch/arm64/kernel/syscall.c:204 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585 Allocated by task 8665: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4c/0x80 mm/kasan/common.c:52 kasan_save_alloc_info+0x24/0x30 mm/kasan/generic.c:505 ____kasan_kmalloc mm/kasan/common.c:374 [inline] __kasan_kmalloc+0xac/0xc4 mm/kasan/common.c:383 kasan_kmalloc include/linux/kasan.h:211 [inline] __do_kmalloc_node mm/slab_common.c:936 [inline] __kmalloc_node+0xe0/0x1d0 mm/slab_common.c:943 kmalloc_node include/linux/slab.h:589 [inline] bpf_map_kmalloc_node+0x21c/0x610 kernel/bpf/syscall.c:452 __dev_map_alloc_node+0x70/0x448 kernel/bpf/devmap.c:851 __dev_map_update_elem kernel/bpf/devmap.c:916 [inline] dev_map_update_elem+0x1a8/0x388 kernel/bpf/devmap.c:935 bpf_map_update_value+0x5e8/0x844 kernel/bpf/syscall.c:226 map_update_elem+0x538/0x6b8 kernel/bpf/syscall.c:1463 __sys_bpf+0x2dc/0x654 kernel/bpf/syscall.c:5013 __do_sys_bpf kernel/bpf/syscall.c:5129 [inline] __se_sys_bpf kernel/bpf/syscall.c:5127 [inline] __arm64_sys_bpf+0x80/0x98 kernel/bpf/syscall.c:5127 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2bc arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140 do_el0_svc+0x58/0x13c arch/arm64/kernel/syscall.c:204 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585 Freed by task 55: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4c/0x80 mm/kasan/common.c:52 kasan_save_free_info+0x38/0x5c mm/kasan/generic.c:516 ____kasan_slab_free+0x144/0x1c0 mm/kasan/common.c:236 __kasan_slab_free+0x18/0x28 mm/kasan/common.c:244 kasan_slab_free include/linux/kasan.h:177 [inline] slab_free_hook mm/slub.c:1724 [inline] slab_free_freelist_hook mm/slub.c:1750 [inline] slab_free mm/slub.c:3661 [inline] __kmem_cache_free+0x2c0/0x4b4 mm/slub.c:3674 kfree+0xcc/0x1b8 mm/slab_common.c:988 dev_map_free+0x4a4/0x5f0 kernel/bpf/devmap.c:238 bpf_map_free_deferred+0xbc/0xd0 kernel/bpf/syscall.c:635 process_one_work+0x804/0x1484 kernel/workqueue.c:2292 worker_thread+0x8e4/0xfec kernel/workqueue.c:2439 kthread+0x250/0x2d8 kernel/kthread.c:376 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:864 Last potentially related work creation: kasan_save_stack+0x40/0x70 mm/kasan/common.c:45 __kasan_record_aux_stack+0xcc/0xe8 mm/kasan/generic.c:486 kasan_record_aux_stack_noalloc+0x14/0x20 mm/kasan/generic.c:496 call_rcu+0xfc/0xa40 kernel/rcu/tree.c:2845 nf_hook_entries_free net/netfilter/core.c:88 [inline] __nf_register_net_hook+0x658/0x7f8 net/netfilter/core.c:445 nf_register_net_hook+0xc4/0x1a4 net/netfilter/core.c:566 nf_register_net_hooks+0x58/0x1b4 net/netfilter/core.c:582 nf_nat_register_fn+0x3b4/0x510 net/netfilter/nf_nat_core.c:1039 nf_nat_ipv6_register_fn+0x5c/0x74 net/netfilter/nf_nat_proto.c:1063 ip6t_nat_register_lookups net/ipv6/netfilter/ip6table_nat.c:79 [inline] ip6table_nat_table_init+0xe0/0x2f4 net/ipv6/netfilter/ip6table_nat.c:123 xt_find_table_lock+0x22c/0x3c8 net/netfilter/x_tables.c:1259 xt_request_find_table_lock+0x38/0x118 net/netfilter/x_tables.c:1284 get_info net/ipv6/netfilter/ip6_tables.c:981 [inline] do_ip6t_get_ctl+0x7bc/0x1784 net/ipv6/netfilter/ip6_tables.c:1670 nf_getsockopt+0x264/0x284 net/netfilter/nf_sockopt.c:116 ipv6_getsockopt+0x2dc/0x444 net/ipv6/ipv6_sockglue.c:1512 tcp_getsockopt+0xcc/0xe8 net/ipv4/tcp.c:4450 sock_common_getsockopt+0xa8/0xc4 net/core/sock.c:3655 __sys_getsockopt+0x1e8/0x484 net/socket.c:2332 __do_sys_getsockopt net/socket.c:2347 [inline] __se_sys_getsockopt net/socket.c:2344 [inline] __arm64_sys_getsockopt+0xb8/0xd4 net/socket.c:2344 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2bc arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140 do_el0_svc+0x58/0x13c arch/arm64/kernel/syscall.c:204 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585 Second to last potentially related work creation: kasan_save_stack+0x40/0x70 mm/kasan/common.c:45 __kasan_record_aux_stack+0xcc/0xe8 mm/kasan/generic.c:486 kasan_record_aux_stack_noalloc+0x14/0x20 mm/kasan/generic.c:496 call_rcu+0xfc/0xa40 kernel/rcu/tree.c:2845 nf_hook_entries_free net/netfilter/core.c:88 [inline] __nf_register_net_hook+0x658/0x7f8 net/netfilter/core.c:445 nf_register_net_hook+0xc4/0x1a4 net/netfilter/core.c:566 nf_register_net_hooks+0x58/0x1b4 net/netfilter/core.c:582 nf_ct_netns_do_get+0x19c/0x558 net/netfilter/nf_conntrack_proto.c:500 nf_ct_netns_inet_get+0x4c/0x168 net/netfilter/nf_conntrack_proto.c:595 nf_ct_netns_get+0x4c/0xd8 net/netfilter/nf_conntrack_proto.c:613 nf_conncount_init+0x120/0x314 net/netfilter/nf_conncount.c:542 ovs_ct_limit_init net/openvswitch/conntrack.c:1902 [inline] ovs_ct_init+0x258/0x3b4 net/openvswitch/conntrack.c:2311 ovs_init_net+0x1e8/0x264 net/openvswitch/datapath.c:2613 ops_init+0x2e4/0x53c net/core/net_namespace.c:138 setup_net+0x46c/0xb88 net/core/net_namespace.c:336 copy_net_ns+0x2ec/0x58c net/core/net_namespace.c:508 create_new_namespaces+0x344/0x614 kernel/nsproxy.c:110 unshare_nsproxy_namespaces+0x108/0x158 kernel/nsproxy.c:226 ksys_unshare+0x424/0x7e4 kernel/fork.c:3201 __do_sys_unshare kernel/fork.c:3272 [inline] __se_sys_unshare kernel/fork.c:3270 [inline] __arm64_sys_unshare+0x3c/0x50 kernel/fork.c:3270 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2bc arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140 do_el0_svc+0x58/0x13c arch/arm64/kernel/syscall.c:204 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585 The buggy address belongs to the object at ffff0000cd498a00 which belongs to the cache kmalloc-cg-128 of size 128 The buggy address is located 0 bytes inside of 128-byte region [ffff0000cd498a00, ffff0000cd498a80) The buggy address belongs to the physical page: page:000000001016f79a refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10d498 memcg:ffff0000d460fd01 flags: 0x5ffc00000000200(slab|node=0|zone=2|lastcpupid=0x7ff) raw: 05ffc00000000200 fffffc0003502f80 dead000000000003 ffff0000c0002d80 raw: 0000000000000000 0000000000100010 00000001ffffffff ffff0000d460fd01 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff0000cd498900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fc ffff0000cd498980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff0000cd498a00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff0000cd498a80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff0000cd498b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc ==================================================================