================================================================== BUG: KASAN: slab-use-after-free in dev_map_generic_redirect+0x554/0x5f0 kernel/bpf/devmap.c:681 Read of size 8 at addr ffff88802f3ac480 by task syz.4.730/8223 CPU: 1 PID: 8223 Comm: syz.4.730 Not tainted 6.10.0-rc7-syzkaller-00076-g9d9a2f29aefd #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:114 print_address_description mm/kasan/report.c:377 [inline] print_report+0xc3/0x620 mm/kasan/report.c:488 kasan_report+0xd9/0x110 mm/kasan/report.c:601 dev_map_generic_redirect+0x554/0x5f0 kernel/bpf/devmap.c:681 xdp_do_generic_redirect_map net/core/filter.c:4490 [inline] xdp_do_generic_redirect+0x309/0x720 net/core/filter.c:4549 do_xdp_generic+0x77f/0xc30 net/core/dev.c:5108 tun_get_user+0x1d36/0x3c30 drivers/net/tun.c:1924 tun_chr_write_iter+0xe8/0x210 drivers/net/tun.c:2048 new_sync_write fs/read_write.c:497 [inline] vfs_write+0x6b9/0x1140 fs/read_write.c:590 ksys_write+0x12f/0x260 fs/read_write.c:643 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7ff127b7475f 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:00007ff1289ae010 EFLAGS: 00000293 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007ff127d03f60 RCX: 00007ff127b7475f RDX: 000000000000fdef RSI: 0000000020000900 RDI: 00000000000000c8 RBP: 00007ff127be4e60 R08: 0000000000000000 R09: 0000000000000000 R10: 000000000000fdef R11: 0000000000000293 R12: 0000000000000000 R13: 000000000000000b R14: 00007ff127d03f60 R15: 00007ffcdc5ff828 Allocated by task 7757: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:370 [inline] __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:387 kmalloc_noprof include/linux/slab.h:660 [inline] alloc_fdtable+0xa0/0x290 fs/file.c:132 dup_fd+0x7da/0xcd0 fs/file.c:359 copy_files kernel/fork.c:1792 [inline] copy_process+0x261b/0x8f10 kernel/fork.c:2378 kernel_clone+0xfd/0x980 kernel/fork.c:2797 __do_sys_clone+0xba/0x100 kernel/fork.c:2940 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 8173: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:579 poison_slab_object+0xf7/0x160 mm/kasan/common.c:240 __kasan_slab_free+0x32/0x50 mm/kasan/common.c:256 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2196 [inline] slab_free mm/slub.c:4438 [inline] kfree+0x12a/0x3b0 mm/slub.c:4559 __free_fdtable fs/file.c:38 [inline] put_files_struct fs/file.c:456 [inline] put_files_struct+0x2b6/0x360 fs/file.c:449 exit_files+0x82/0xb0 fs/file.c:469 do_exit+0xa67/0x2ba0 kernel/exit.c:871 do_group_exit+0xd3/0x2a0 kernel/exit.c:1025 __do_sys_exit_group kernel/exit.c:1036 [inline] __se_sys_exit_group kernel/exit.c:1034 [inline] __x64_sys_exit_group+0x3e/0x50 kernel/exit.c:1034 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f The buggy address belongs to the object at ffff88802f3ac480 which belongs to the cache kmalloc-cg-64 of size 64 The buggy address is located 0 bytes inside of freed 64-byte region [ffff88802f3ac480, ffff88802f3ac4c0) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2f3ac memcg:ffff88807c6e0401 anon flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffefff(slab) raw: 00fff00000000000 ffff88801544dc80 0000000000000000 0000000000000001 raw: 0000000000000000 0000000000200020 00000001ffffefff ffff88807c6e0401 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x252800(GFP_NOWAIT|__GFP_NORETRY|__GFP_COMP|__GFP_THISNODE), pid 1, tgid 1 (swapper/0), ts 32345094852, free_ts 32337293715 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x2d1/0x350 mm/page_alloc.c:1473 prep_new_page mm/page_alloc.c:1481 [inline] get_page_from_freelist+0x1353/0x2e50 mm/page_alloc.c:3425 __alloc_pages_noprof+0x22b/0x2460 mm/page_alloc.c:4683 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline] alloc_pages_node_noprof include/linux/gfp.h:296 [inline] alloc_slab_page+0x56/0x110 mm/slub.c:2265 allocate_slab mm/slub.c:2428 [inline] new_slab+0x84/0x260 mm/slub.c:2481 ___slab_alloc+0xdac/0x1870 mm/slub.c:3667 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3757 __slab_alloc_node mm/slub.c:3810 [inline] slab_alloc_node mm/slub.c:3990 [inline] __do_kmalloc_node mm/slub.c:4122 [inline] __kmalloc_node_noprof+0x35c/0x440 mm/slub.c:4130 kmalloc_node_noprof include/linux/slab.h:681 [inline] __alloc+0x13c/0x190 kernel/bpf/memalloc.c:153 alloc_bulk+0x3e1/0x600 kernel/bpf/memalloc.c:247 prefill_mem_cache kernel/bpf/memalloc.c:503 [inline] bpf_mem_alloc_init+0x37c/0xd00 kernel/bpf/memalloc.c:573 bpf_global_ma_init+0x1a/0x40 kernel/bpf/core.c:3054 do_one_initcall+0x12b/0x700 init/main.c:1267 do_initcall_level init/main.c:1329 [inline] do_initcalls init/main.c:1345 [inline] do_basic_setup init/main.c:1364 [inline] kernel_init_freeable+0x69d/0xca0 init/main.c:1578 kernel_init+0x1c/0x2b0 init/main.c:1467 ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:147 page last free pid 9 tgid 9 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1093 [inline] free_unref_page+0x64a/0xe40 mm/page_alloc.c:2588 vfree+0x181/0x7a0 mm/vmalloc.c:3363 delayed_vfree_work+0x56/0x70 mm/vmalloc.c:3284 process_one_work+0x9c8/0x1b40 kernel/workqueue.c:3248 process_scheduled_works kernel/workqueue.c:3329 [inline] worker_thread+0x6c8/0xf30 kernel/workqueue.c:3409 kthread+0x2c4/0x3a0 kernel/kthread.c:389 ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 Memory state around the buggy address: ffff88802f3ac380: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc ffff88802f3ac400: 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc >ffff88802f3ac480: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ^ ffff88802f3ac500: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc ffff88802f3ac580: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ================================================================== ================================================================== BUG: KASAN: slab-use-after-free in xdp_ok_fwd_dev include/linux/filter.h:1049 [inline] BUG: KASAN: slab-use-after-free in dev_map_generic_redirect+0x508/0x5f0 kernel/bpf/devmap.c:681 Read of size 4 at addr ffff88802f0ae270 by task syz.4.730/8223 CPU: 1 PID: 8223 Comm: syz.4.730 Tainted: G B 6.10.0-rc7-syzkaller-00076-g9d9a2f29aefd #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:114 print_address_description mm/kasan/report.c:377 [inline] print_report+0xc3/0x620 mm/kasan/report.c:488 kasan_report+0xd9/0x110 mm/kasan/report.c:601 xdp_ok_fwd_dev include/linux/filter.h:1049 [inline] dev_map_generic_redirect+0x508/0x5f0 kernel/bpf/devmap.c:681 xdp_do_generic_redirect_map net/core/filter.c:4490 [inline] xdp_do_generic_redirect+0x309/0x720 net/core/filter.c:4549 do_xdp_generic+0x77f/0xc30 net/core/dev.c:5108 tun_get_user+0x1d36/0x3c30 drivers/net/tun.c:1924 tun_chr_write_iter+0xe8/0x210 drivers/net/tun.c:2048 new_sync_write fs/read_write.c:497 [inline] vfs_write+0x6b9/0x1140 fs/read_write.c:590 ksys_write+0x12f/0x260 fs/read_write.c:643 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7ff127b7475f 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:00007ff1289ae010 EFLAGS: 00000293 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007ff127d03f60 RCX: 00007ff127b7475f RDX: 000000000000fdef RSI: 0000000020000900 RDI: 00000000000000c8 RBP: 00007ff127be4e60 R08: 0000000000000000 R09: 0000000000000000 R10: 000000000000fdef R11: 0000000000000293 R12: 0000000000000000 R13: 000000000000000b R14: 00007ff127d03f60 R15: 00007ffcdc5ff828 Allocated by task 7757: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 unpoison_slab_object mm/kasan/common.c:312 [inline] __kasan_slab_alloc+0x89/0x90 mm/kasan/common.c:338 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook mm/slub.c:3940 [inline] slab_alloc_node mm/slub.c:4002 [inline] kmem_cache_alloc_noprof+0x121/0x2f0 mm/slub.c:4009 dup_fd+0x8c/0xcd0 fs/file.c:329 copy_files kernel/fork.c:1792 [inline] copy_process+0x261b/0x8f10 kernel/fork.c:2378 kernel_clone+0xfd/0x980 kernel/fork.c:2797 __do_sys_clone+0xba/0x100 kernel/fork.c:2940 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 8173: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:579 poison_slab_object+0xf7/0x160 mm/kasan/common.c:240 __kasan_slab_free+0x32/0x50 mm/kasan/common.c:256 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2196 [inline] slab_free mm/slub.c:4438 [inline] kmem_cache_free+0x12f/0x3a0 mm/slub.c:4513 put_files_struct fs/file.c:457 [inline] put_files_struct+0x2e7/0x360 fs/file.c:449 exit_files+0x82/0xb0 fs/file.c:469 do_exit+0xa67/0x2ba0 kernel/exit.c:871 do_group_exit+0xd3/0x2a0 kernel/exit.c:1025 __do_sys_exit_group kernel/exit.c:1036 [inline] __se_sys_exit_group kernel/exit.c:1034 [inline] __x64_sys_exit_group+0x3e/0x50 kernel/exit.c:1034 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f The buggy address belongs to the object at ffff88802f0ae1c0 which belongs to the cache files_cache of size 832 The buggy address is located 176 bytes inside of freed 832-byte region [ffff88802f0ae1c0, ffff88802f0ae500) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2f0ac head: order:2 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 memcg:ffff88802fa21801 anon flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffefff(slab) raw: 00fff00000000040 ffff8880166a88c0 ffffea0000bc2c00 dead000000000005 raw: 0000000000000000 0000000000110011 00000001ffffefff ffff88802fa21801 head: 00fff00000000040 ffff8880166a88c0 ffffea0000bc2c00 dead000000000005 head: 0000000000000000 0000000000110011 00000001ffffefff ffff88802fa21801 head: 00fff00000000002 ffffea0000bc2b01 ffffffffffffffff 0000000000000000 head: 0000000000000004 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 986, tgid 986 (kworker/u8:5), ts 32273116953, free_ts 0 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x2d1/0x350 mm/page_alloc.c:1473 prep_new_page mm/page_alloc.c:1481 [inline] get_page_from_freelist+0x1353/0x2e50 mm/page_alloc.c:3425 __alloc_pages_noprof+0x22b/0x2460 mm/page_alloc.c:4683 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline] alloc_pages_node_noprof include/linux/gfp.h:296 [inline] alloc_slab_page+0x56/0x110 mm/slub.c:2265 allocate_slab mm/slub.c:2428 [inline] new_slab+0x84/0x260 mm/slub.c:2481 ___slab_alloc+0xdac/0x1870 mm/slub.c:3667 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3757 __slab_alloc_node mm/slub.c:3810 [inline] slab_alloc_node mm/slub.c:3990 [inline] kmem_cache_alloc_noprof+0x2a7/0x2f0 mm/slub.c:4009 dup_fd+0x8c/0xcd0 fs/file.c:329 copy_files kernel/fork.c:1792 [inline] copy_process+0x261b/0x8f10 kernel/fork.c:2378 kernel_clone+0xfd/0x980 kernel/fork.c:2797 user_mode_thread+0xb4/0xf0 kernel/fork.c:2875 call_usermodehelper_exec_work kernel/umh.c:172 [inline] call_usermodehelper_exec_work+0xcb/0x170 kernel/umh.c:158 process_one_work+0x9c8/0x1b40 kernel/workqueue.c:3248 process_scheduled_works kernel/workqueue.c:3329 [inline] worker_thread+0x6c8/0xf30 kernel/workqueue.c:3409 kthread+0x2c4/0x3a0 kernel/kthread.c:389 page_owner free stack trace missing Memory state around the buggy address: ffff88802f0ae100: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff88802f0ae180: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb >ffff88802f0ae200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88802f0ae280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88802f0ae300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================