================================================================== BUG: KASAN: use-after-free in dev_map_generic_redirect+0x9f/0x7d0 kernel/bpf/devmap.c:665 Read of size 8 at addr ffff888108e87800 by task syz.3.3031/6679 CPU: 0 PID: 6679 Comm: syz.3.3031 Not tainted 6.1.112-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+0x151/0x1b7 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:284 [inline] print_report+0x158/0x4e0 mm/kasan/report.c:395 kasan_report+0x13c/0x170 mm/kasan/report.c:495 __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:4947 __netif_receive_skb_core+0x1877/0x3bb0 net/core/dev.c:5349 __netif_receive_skb_one_core net/core/dev.c:5526 [inline] __netif_receive_skb+0x11c/0x530 net/core/dev.c:5642 netif_receive_skb_internal net/core/dev.c:5728 [inline] netif_receive_skb+0xb0/0x480 net/core/dev.c:5787 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:2265 [inline] new_sync_write fs/read_write.c:491 [inline] vfs_write+0xa6b/0xe50 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:0x7fb14777d1ff 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:00007fb148660000 EFLAGS: 00000293 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007fb147935f80 RCX: 00007fb14777d1ff RDX: 000000000000006a RSI: 0000000020000180 RDI: 00000000000000c8 RBP: 00007fb1477f1616 R08: 0000000000000000 R09: 0000000000000000 R10: 000000000000006a R11: 0000000000000293 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fb147935f80 R15: 00007ffc5f493b18 Allocated by task 6671: 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:374 [inline] __kasan_kmalloc+0x9c/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+0xb4/0x1e0 mm/slab_common.c:943 kmalloc_node include/linux/slab.h:583 [inline] bpf_map_kmalloc_node+0xd0/0x2c0 kernel/bpf/syscall.c:452 __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:226 map_update_elem+0x500/0x680 kernel/bpf/syscall.c:1463 __sys_bpf+0x340/0x6d0 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+0x7c/0x90 kernel/bpf/syscall.c:5122 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 613: 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:236 __kasan_slab_free+0x11/0x20 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+0x218/0x3b0 mm/slub.c:3674 kfree+0x7a/0xf0 mm/slab_common.c:988 dev_map_free+0x596/0x6c0 kernel/bpf/devmap.c:238 bpf_map_free_deferred+0xf7/0x1b0 kernel/bpf/syscall.c:635 process_one_work+0x73d/0xcb0 kernel/workqueue.c:2292 worker_thread+0xa5d/0x1260 kernel/workqueue.c:2439 kthread+0x26d/0x300 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 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 kvfree_call_rcu+0x9f/0x800 kernel/rcu/tree.c:3401 kernfs_unlink_open_file+0x34f/0x400 fs/kernfs/file.c:635 kernfs_fop_release+0x230/0x2f0 fs/kernfs/file.c:807 __fput+0x1e5/0x870 fs/file_table.c:320 ____fput+0x15/0x20 fs/file_table.c:348 task_work_run+0x24d/0x2e0 kernel/task_work.c:203 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop+0x94/0xa0 kernel/entry/common.c:177 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:210 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline] syscall_exit_to_user_mode+0x26/0x130 kernel/entry/common.c:303 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87 entry_SYSCALL_64_after_hwframe+0x68/0xd2 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 kvfree_call_rcu+0x9f/0x800 kernel/rcu/tree.c:3401 kernfs_unlink_open_file+0x34f/0x400 fs/kernfs/file.c:635 kernfs_fop_release+0x230/0x2f0 fs/kernfs/file.c:807 __fput+0x1e5/0x870 fs/file_table.c:320 ____fput+0x15/0x20 fs/file_table.c:348 task_work_run+0x24d/0x2e0 kernel/task_work.c:203 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop+0x94/0xa0 kernel/entry/common.c:177 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:210 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline] syscall_exit_to_user_mode+0x26/0x130 kernel/entry/common.c:303 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87 entry_SYSCALL_64_after_hwframe+0x68/0xd2 The buggy address belongs to the object at ffff888108e87800 which belongs to the cache kmalloc-96 of size 96 The buggy address is located 0 bytes inside of 96-byte region [ffff888108e87800, ffff888108e87860) The buggy address belongs to the physical page: page:ffffea000423a1c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x108e87 flags: 0x4000000000000200(slab|zone=1) raw: 4000000000000200 ffffea0004852100 dead000000000003 ffff888100041780 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 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 1, tgid 1 (swapper/0), ts 1295781167, free_ts 0 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x1e2/0x1f0 mm/page_alloc.c:2517 prep_new_page mm/page_alloc.c:2524 [inline] get_page_from_freelist+0x2e1c/0x2ef0 mm/page_alloc.c:4290 __alloc_pages+0x3c2/0x7d0 mm/page_alloc.c:5558 allocate_slab mm/slub.c:1939 [inline] new_slab+0xce/0x4c0 mm/slub.c:1992 ___slab_alloc+0x6f9/0xb80 mm/slub.c:3180 __slab_alloc+0x5d/0xa0 mm/slub.c:3279 slab_alloc_node mm/slub.c:3364 [inline] __kmem_cache_alloc_node+0x1af/0x250 mm/slub.c:3437 kmalloc_trace+0x2a/0xa0 mm/slab_common.c:1026 kmalloc include/linux/slab.h:557 [inline] kzalloc include/linux/slab.h:693 [inline] locate_module_kobject+0x74/0x164 kernel/params.c:771 kernel_add_sysfs_param+0x24/0x12d kernel/params.c:803 param_sysfs_builtin+0x210/0x2b5 kernel/params.c:851 param_sysfs_init+0x6a/0x6f kernel/params.c:970 do_one_initcall+0x18d/0x630 init/main.c:1298 do_initcall_level+0x186/0x306 init/main.c:1371 do_initcalls+0x4e/0x8e init/main.c:1387 do_basic_setup+0x81/0x8a init/main.c:1406 page_owner free stack trace missing Memory state around the buggy address: ffff888108e87700: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc ffff888108e87780: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc >ffff888108e87800: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ^ ffff888108e87880: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc ffff888108e87900: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ==================================================================