================================================================== BUG: KASAN: use-after-free in dev_map_generic_redirect+0x9f/0x7d0 kernel/bpf/devmap.c:665 Read of size 8 at addr ffff888117da6e80 by task syz.2.2196/7765 CPU: 1 PID: 7765 Comm: syz.2.2196 Not tainted 6.1.90-syzkaller-00115-gdd8ee5c24218 #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+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 dev_map_generic_redirect+0x9f/0x7d0 kernel/bpf/devmap.c:665 xdp_do_generic_redirect_map net/core/filter.c:4355 [inline] xdp_do_generic_redirect+0x411/0xad0 net/core/filter.c:4412 do_xdp_generic+0x53e/0x800 net/core/dev.c:4954 tun_get_user+0x238a/0x3a90 drivers/net/tun.c:1920 tun_chr_write_iter+0x129/0x210 drivers/net/tun.c:2044 call_write_iter include/linux/fs.h:2274 [inline] new_sync_write fs/read_write.c:491 [inline] vfs_write+0x902/0xeb0 fs/read_write.c:584 ksys_write+0x199/0x2c0 fs/read_write.c:637 __do_sys_write fs/read_write.c:649 [inline] __se_sys_write fs/read_write.c:646 [inline] __x64_sys_write+0x7b/0x90 fs/read_write.c:646 x64_sys_call+0x2f/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:2 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:0x7fd278f74a9f 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:00007fd279c93010 EFLAGS: 00000293 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007fd279105f60 RCX: 00007fd278f74a9f RDX: 0000000000000d86 RSI: 0000000020001580 RDI: 00000000000000c8 RBP: 00007fd278fe4e68 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000d86 R11: 0000000000000293 R12: 0000000000000000 R13: 000000000000000b R14: 00007fd279105f60 R15: 00007ffe6ddc2de8 Allocated by task 6918: 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] __do_kmalloc_node mm/slab_common.c:957 [inline] __kmalloc_node+0xb4/0x1e0 mm/slab_common.c:964 kmalloc_node include/linux/slab.h:582 [inline] bpf_map_kmalloc_node+0xd0/0x2c0 kernel/bpf/syscall.c:454 __dev_map_alloc_node+0x5c/0x4e0 kernel/bpf/devmap.c:848 __dev_map_hash_update_elem kernel/bpf/devmap.c:958 [inline] dev_map_hash_update_elem+0x32b/0x7b0 kernel/bpf/devmap.c:992 bpf_map_update_value+0x23a/0x410 kernel/bpf/syscall.c:228 map_update_elem+0x500/0x680 kernel/bpf/syscall.c:1428 __sys_bpf+0x460/0x7f0 kernel/bpf/syscall.c:4975 __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 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 __call_rcu_common kernel/rcu/tree.c:2806 [inline] call_rcu+0xee/0x1340 kernel/rcu/tree.c:2925 nf_hook_entries_free net/netfilter/core.c:94 [inline] __nf_unregister_net_hook+0x4bc/0x680 net/netfilter/core.c:520 nf_unregister_net_hooks+0xdb/0x140 net/netfilter/core.c:607 nf_nat_unregister_fn+0x27a/0x3d0 net/netfilter/nf_nat_core.c:1100 nf_nat_ipv4_unregister_fn+0x43/0x60 net/netfilter/nf_nat_proto.c:831 ipt_nat_unregister_lookups net/ipv4/netfilter/iptable_nat.c:101 [inline] iptable_nat_net_pre_exit+0xbc/0xe0 net/ipv4/netfilter/iptable_nat.c:131 ops_pre_exit_list net/core/net_namespace.c:159 [inline] cleanup_net+0x522/0xbf0 net/core/net_namespace.c:589 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 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 __call_rcu_common kernel/rcu/tree.c:2806 [inline] call_rcu+0xee/0x1340 kernel/rcu/tree.c:2925 tnode_free net/ipv4/fib_trie.c:496 [inline] replace+0x19b/0x4b0 net/ipv4/fib_trie.c:522 inflate net/ipv4/fib_trie.c:624 [inline] resize+0xbaf/0x1d60 net/ipv4/fib_trie.c:869 trie_rebalance net/ipv4/fib_trie.c:1106 [inline] fib_insert_node net/ipv4/fib_trie.c:1150 [inline] fib_insert_alias+0xb20/0x1060 net/ipv4/fib_trie.c:1164 fib_table_insert+0xa01/0x20a0 net/ipv4/fib_trie.c:1378 fib_magic net/ipv4/fib_frontend.c:1104 [inline] fib_add_ifaddr+0x43f/0x15e0 net/ipv4/fib_frontend.c:1126 fib_inetaddr_event+0x159/0x310 net/ipv4/fib_frontend.c:1440 notifier_call_chain kernel/notifier.c:87 [inline] blocking_notifier_call_chain+0xbb/0x140 kernel/notifier.c:382 __inet_insert_ifa+0x8fb/0xb10 net/ipv4/devinet.c:554 inet_rtm_newaddr+0x8f7/0x1780 net/ipv4/devinet.c:960 rtnetlink_rcv_msg+0x9a5/0xca0 net/core/rtnetlink.c:6121 netlink_rcv_skb+0x1cd/0x410 net/netlink/af_netlink.c:2518 rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:6139 netlink_unicast_kernel net/netlink/af_netlink.c:1327 [inline] netlink_unicast+0x906/0xab0 net/netlink/af_netlink.c:1353 netlink_sendmsg+0xa15/0xd30 net/netlink/af_netlink.c:1875 sock_sendmsg_nosec net/socket.c:716 [inline] __sock_sendmsg net/socket.c:728 [inline] __sys_sendto+0x480/0x600 net/socket.c:2138 __do_sys_sendto net/socket.c:2150 [inline] __se_sys_sendto net/socket.c:2146 [inline] __x64_sys_sendto+0xe5/0x100 net/socket.c:2146 x64_sys_call+0x15c/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:45 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 The buggy address belongs to the object at ffff888117da6e80 which belongs to the cache kmalloc-96 of size 96 The buggy address is located 0 bytes inside of 96-byte region [ffff888117da6e80, ffff888117da6ee0) The buggy address belongs to the physical page: page:ffffea00045f6980 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888117da6980 pfn:0x117da6 flags: 0x4000000000000200(slab|zone=1) raw: 4000000000000200 ffffea0004d95e48 ffffea00045293c8 ffff888100042900 raw: ffff888117da6980 0000000000200015 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 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 113, tgid 113 (udevd), ts 4335830272, free_ts 0 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_get_open_node fs/kernfs/file.c:568 [inline] kernfs_fop_open+0x70e/0xb10 fs/kernfs/file.c:736 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+0x13f/0x850 fs/open.c:1341 page_owner free stack trace missing Memory state around the buggy address: ffff888117da6d80: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ffff888117da6e00: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc >ffff888117da6e80: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ^ ffff888117da6f00: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ffff888117da6f80: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ==================================================================