================================================================== BUG: KASAN: use-after-free in dev_map_generic_redirect+0x9f/0x7d0 kernel/bpf/devmap.c:665 Read of size 8 at addr ffff88812d475880 by task syz.5.666/1911 CPU: 0 PID: 1911 Comm: syz.5.666 Not tainted 6.1.112-syzkaller-00008-g38859a233e31 #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+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:4390 [inline] xdp_do_generic_redirect+0x42e/0xb40 net/core/filter.c:4449 do_xdp_generic+0x53e/0x800 net/core/dev.c:4958 __netif_receive_skb_core+0x19ae/0x43d0 net/core/dev.c:5365 __netif_receive_skb_one_core net/core/dev.c:5542 [inline] __netif_receive_skb+0x11c/0x530 net/core/dev.c:5658 netif_receive_skb_internal net/core/dev.c:5744 [inline] netif_receive_skb+0xb0/0x480 net/core/dev.c:5803 tun_rx_batched+0x1c0/0x8f0 drivers/net/tun.c:1548 tun_get_user+0x287e/0x3a90 drivers/net/tun.c:1998 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+0xaf6/0xed0 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:0x7fd29137d1ff 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:00007fd2920bf000 EFLAGS: 00000293 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007fd291535f80 RCX: 00007fd29137d1ff RDX: 000000000000006a RSI: 0000000020000180 RDI: 00000000000000c8 RBP: 00007fd2913f1616 R08: 0000000000000000 R09: 0000000000000000 R10: 000000000000006a R11: 0000000000000293 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fd291535f80 R15: 00007ffd31c13b48 Allocated by task 1814: 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:938 [inline] __kmalloc_node+0xb4/0x1e0 mm/slab_common.c:945 kmalloc_node include/linux/slab.h:583 [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_update_elem kernel/bpf/devmap.c:913 [inline] dev_map_update_elem+0x20e/0x3f0 kernel/bpf/devmap.c:932 bpf_map_update_value+0x23a/0x410 kernel/bpf/syscall.c:228 map_update_elem+0x500/0x680 kernel/bpf/syscall.c:1443 __sys_bpf+0x460/0x7f0 kernel/bpf/syscall.c:4990 __do_sys_bpf kernel/bpf/syscall.c:5106 [inline] __se_sys_bpf kernel/bpf/syscall.c:5104 [inline] __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5104 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 Freed by task 43: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:516 ____kasan_slab_free+0x131/0x180 mm/kasan/common.c:241 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:249 kasan_slab_free include/linux/kasan.h:178 [inline] slab_free_hook mm/slub.c:1745 [inline] slab_free_freelist_hook mm/slub.c:1771 [inline] slab_free mm/slub.c:3684 [inline] __kmem_cache_free+0x218/0x3b0 mm/slub.c:3697 kfree+0x7a/0xf0 mm/slab_common.c:990 dev_map_free+0x596/0x6c0 kernel/bpf/devmap.c:238 bpf_map_free_deferred+0xf7/0x1b0 kernel/bpf/syscall.c:637 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:295 The buggy address belongs to the object at ffff88812d475880 which belongs to the cache kmalloc-96 of size 96 The buggy address is located 0 bytes inside of 96-byte region [ffff88812d475880, ffff88812d4758e0) The buggy address belongs to the physical page: page:ffffea0004b51d40 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x12d475 flags: 0x4000000000000200(slab|zone=1) raw: 4000000000000200 ffffea0004272980 dead000000000006 ffff888100042900 raw: 0000000000000000 0000000000200020 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 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 372, tgid 372 (udevd), ts 43466310185, free_ts 43445702322 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+0x2980/0x2a10 mm/page_alloc.c:4439 __alloc_pages+0x234/0x610 mm/page_alloc.c:5728 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:1028 kmalloc include/linux/slab.h:557 [inline] kzalloc include/linux/slab.h:693 [inline] kernfs_get_open_node fs/kernfs/file.c:574 [inline] kernfs_fop_open+0x70e/0xb10 fs/kernfs/file.c:742 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+0x151/0x870 fs/open.c:1341 page last free stack trace: reset_page_owner include/linux/page_owner.h:26 [inline] free_pages_prepare mm/page_alloc.c:1498 [inline] free_pcp_prepare mm/page_alloc.c:1572 [inline] free_unref_page_prepare+0x83d/0x850 mm/page_alloc.c:3511 free_unref_page_list+0xf1/0x7b0 mm/page_alloc.c:3659 release_pages+0xf7f/0xfe0 mm/swap.c:1063 free_pages_and_swap_cache+0x8a/0xa0 mm/swap_state.c:315 tlb_batch_pages_flush mm/mmu_gather.c:59 [inline] tlb_flush_mmu_free mm/mmu_gather.c:254 [inline] tlb_flush_mmu mm/mmu_gather.c:261 [inline] tlb_finish_mmu+0x1e0/0x3f0 mm/mmu_gather.c:361 exit_mmap+0x460/0xbe0 mm/mmap.c:3348 __mmput+0x95/0x310 kernel/fork.c:1298 mmput+0x56/0x170 kernel/fork.c:1321 exit_mm kernel/exit.c:568 [inline] do_exit+0xb29/0x2b80 kernel/exit.c:864 do_group_exit+0x21a/0x2d0 kernel/exit.c:1027 __do_sys_exit_group kernel/exit.c:1038 [inline] __se_sys_exit_group kernel/exit.c:1036 [inline] __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1036 x64_sys_call+0x610/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:232 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: ffff88812d475780: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ffff88812d475800: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc >ffff88812d475880: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ^ ffff88812d475900: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc ffff88812d475980: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ==================================================================