================================================================== BUG: KASAN: use-after-free in dev_map_generic_redirect+0xa0/0x650 kernel/bpf/devmap.c:668 Read of size 8 at addr ffff8880307a5c80 by task syz.0.785/7338 CPU: 1 PID: 7338 Comm: syz.0.785 Not tainted 6.1.116-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_generic_redirect+0xa0/0x650 kernel/bpf/devmap.c:668 xdp_do_generic_redirect_map net/core/filter.c:4392 [inline] xdp_do_generic_redirect+0x4bf/0x850 net/core/filter.c:4451 do_xdp_generic+0x50b/0x6d0 net/core/dev.c:4955 __netif_receive_skb_core+0x1c88/0x41d0 net/core/dev.c:5357 __netif_receive_skb_one_core net/core/dev.c:5534 [inline] __netif_receive_skb+0x11c/0x530 net/core/dev.c:5650 netif_receive_skb_internal net/core/dev.c:5736 [inline] netif_receive_skb+0x1f4/0x890 net/core/dev.c:5795 tun_rx_batched+0x1b3/0x8e0 drivers/net/tun.c:1548 tun_get_user+0x2c03/0x42d0 drivers/net/tun.c:1998 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:0x7f4d8af7d1ff Code: 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 c9 8d 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 1c 8e 02 00 48 RSP: 002b:00007f4d8bdd2000 EFLAGS: 00000293 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007f4d8b135f80 RCX: 00007f4d8af7d1ff RDX: 000000000000006a RSI: 0000000020000180 RDI: 00000000000000c8 RBP: 00007f4d8aff175e R08: 0000000000000000 R09: 0000000000000000 R10: 000000000000006a R11: 0000000000000293 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f4d8b135f80 R15: 00007fff31c5bef8 Allocated by task 7309: 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_update_elem kernel/bpf/devmap.c:916 [inline] dev_map_update_elem+0x1eb/0x3c0 kernel/bpf/devmap.c:935 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 Freed by task 9: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:52 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:516 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236 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+0x25c/0x3c0 mm/slub.c:3674 dev_map_free+0x56c/0x680 kernel/bpf/devmap.c:238 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 ffff8880307a5c80 which belongs to the cache kmalloc-cg-96 of size 96 The buggy address is located 0 bytes inside of 96-byte region [ffff8880307a5c80, ffff8880307a5ce0) The buggy address belongs to the physical page: page:ffffea0000c1e940 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880307a5580 pfn:0x307a5 memcg:ffff88807cafb201 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffffea000184ab40 dead000000000004 ffff888017c428c0 raw: ffff8880307a5580 000000008020001e 00000001ffffffff ffff88807cafb201 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 4250, tgid 4250 (syz-executor), ts 85818261243, free_ts 85817834745 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+0x3731/0x38d0 mm/page_alloc.c:4313 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5589 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] alloc_fdtable+0x154/0x280 fs/file.c:137 dup_fd+0x95c/0xca0 fs/file.c:336 copy_files+0x72/0xe0 kernel/fork.c:1635 copy_process+0x1873/0x4060 kernel/fork.c:2252 kernel_clone+0x222/0x920 kernel/fork.c:2679 __do_sys_clone kernel/fork.c:2820 [inline] __se_sys_clone kernel/fork.c:2804 [inline] __x64_sys_clone+0x231/0x280 kernel/fork.c:2804 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81 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 __do_replace+0x891/0xa70 net/ipv6/netfilter/ip6_tables.c:1109 do_replace net/ipv6/netfilter/ip6_tables.c:1160 [inline] do_ip6t_set_ctl+0xef2/0x1250 net/ipv6/netfilter/ip6_tables.c:1646 nf_setsockopt+0x28a/0x2b0 net/netfilter/nf_sockopt.c:101 __sys_setsockopt+0x57e/0xa00 net/socket.c:2288 __do_sys_setsockopt net/socket.c:2299 [inline] __se_sys_setsockopt net/socket.c:2296 [inline] __x64_sys_setsockopt+0xb1/0xc0 net/socket.c:2296 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: ffff8880307a5b80: 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc ffff8880307a5c00: 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc >ffff8880307a5c80: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ^ ffff8880307a5d00: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ffff8880307a5d80: 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc ==================================================================