================================================================== BUG: KASAN: slab-use-after-free in dev_map_enqueue+0x40/0x3e0 kernel/bpf/devmap.c:539 Read of size 8 at addr ffff88807cf9cf80 by task syz.2.2056/10463 CPU: 1 PID: 10463 Comm: syz.2.2056 Not tainted 6.10.0-rc6-syzkaller-00158-g0005b2dc43f9 #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+0x241/0x360 lib/dump_stack.c:114 print_address_description mm/kasan/report.c:377 [inline] print_report+0x169/0x550 mm/kasan/report.c:488 kasan_report+0x143/0x180 mm/kasan/report.c:601 dev_map_enqueue+0x40/0x3e0 kernel/bpf/devmap.c:539 __xdp_do_redirect_frame net/core/filter.c:4402 [inline] xdp_do_redirect_frame+0x2a6/0x660 net/core/filter.c:4456 xdp_test_run_batch net/bpf/test_run.c:336 [inline] bpf_test_run_xdp_live+0xe60/0x1e60 net/bpf/test_run.c:384 bpf_prog_test_run_xdp+0x80e/0x11b0 net/bpf/test_run.c:1281 bpf_prog_test_run+0x33a/0x3b0 kernel/bpf/syscall.c:4292 __sys_bpf+0x48d/0x810 kernel/bpf/syscall.c:5706 __do_sys_bpf kernel/bpf/syscall.c:5795 [inline] __se_sys_bpf kernel/bpf/syscall.c:5793 [inline] __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5793 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f802a375bd9 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f8029dde048 EFLAGS: 00000246 ORIG_RAX: 0000000000000141 RAX: ffffffffffffffda RBX: 00007f802a504110 RCX: 00007f802a375bd9 RDX: 0000000000000050 RSI: 0000000020000600 RDI: 000000000000000a RBP: 00007f802a3e4aa1 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 000000000000006e R14: 00007f802a504110 R15: 00007ffe27f49aa8 Allocated by task 7180: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:370 [inline] __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:387 kasan_kmalloc include/linux/kasan.h:211 [inline] __do_kmalloc_node mm/slub.c:4123 [inline] __kmalloc_node_noprof+0x22a/0x440 mm/slub.c:4130 kmalloc_node_noprof include/linux/slab.h:681 [inline] bpf_map_kmalloc_node+0xd3/0x1c0 kernel/bpf/syscall.c:422 __dev_map_alloc_node+0x56/0x4a0 kernel/bpf/devmap.c:863 __dev_map_hash_update_elem kernel/bpf/devmap.c:974 [inline] dev_map_hash_update_elem+0x307/0x780 kernel/bpf/devmap.c:1008 bpf_map_update_value+0x4d3/0x540 kernel/bpf/syscall.c:203 map_update_elem+0x53a/0x6f0 kernel/bpf/syscall.c:1654 __sys_bpf+0x76f/0x810 kernel/bpf/syscall.c:5676 __do_sys_bpf kernel/bpf/syscall.c:5795 [inline] __se_sys_bpf kernel/bpf/syscall.c:5793 [inline] __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5793 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 2462: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579 poison_slab_object+0xe0/0x150 mm/kasan/common.c:240 __kasan_slab_free+0x37/0x60 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+0x149/0x360 mm/slub.c:4559 dev_map_free+0x397/0x680 kernel/bpf/devmap.c:218 bpf_map_free_deferred+0xe6/0x110 kernel/bpf/syscall.c:746 process_one_work kernel/workqueue.c:3248 [inline] process_scheduled_works+0xa2c/0x1830 kernel/workqueue.c:3329 worker_thread+0x86d/0xd50 kernel/workqueue.c:3409 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 The buggy address belongs to the object at ffff88807cf9cf80 which belongs to the cache kmalloc-cg-64 of size 64 The buggy address is located 0 bytes inside of freed 64-byte region [ffff88807cf9cf80, ffff88807cf9cfc0) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88807cf9cc00 pfn:0x7cf9c memcg:ffff88807e63ba01 anon flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffefff(slab) raw: 00fff00000000000 ffff88801504dc80 0000000000000000 dead000000000001 raw: ffff88807cf9cc00 000000000020000b 00000001ffffefff ffff88807e63ba01 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x152cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 5108, tgid 5108 (syz-executor), ts 86204183184, free_ts 86203536043 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1473 prep_new_page mm/page_alloc.c:1481 [inline] get_page_from_freelist+0x2e4c/0x2f10 mm/page_alloc.c:3425 __alloc_pages_noprof+0x256/0x6c0 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+0x5f/0x120 mm/slub.c:2265 allocate_slab+0x5a/0x2f0 mm/slub.c:2428 new_slab mm/slub.c:2481 [inline] ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3667 __slab_alloc+0x58/0xa0 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+0x286/0x440 mm/slub.c:4130 kmalloc_node_noprof include/linux/slab.h:681 [inline] kvmalloc_node_noprof+0x72/0x190 mm/util.c:634 allocate_hook_entries_size net/netfilter/core.c:61 [inline] nf_hook_entries_grow+0x288/0x720 net/netfilter/core.c:140 nf_hook_entries_insert_raw+0x4d/0x310 net/netfilter/core.c:204 nf_nat_register_fn+0x1c7/0x570 net/netfilter/nf_nat_core.c:1145 ipt_nat_register_lookups net/ipv4/netfilter/iptable_nat.c:77 [inline] iptable_nat_table_init+0x1f7/0x2d0 net/ipv4/netfilter/iptable_nat.c:121 xt_find_table_lock+0x2d4/0x3b0 net/netfilter/x_tables.c:1260 xt_request_find_table_lock+0x26/0x100 net/netfilter/x_tables.c:1285 get_info net/ipv4/netfilter/ip_tables.c:963 [inline] do_ipt_get_ctl+0x89e/0x1810 net/ipv4/netfilter/ip_tables.c:1659 page last free pid 5108 tgid 5108 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1093 [inline] free_unref_page+0xd22/0xea0 mm/page_alloc.c:2588 vfree+0x186/0x2e0 mm/vmalloc.c:3355 copy_entries_to_user net/ipv4/netfilter/ip_tables.c:866 [inline] get_entries net/ipv4/netfilter/ip_tables.c:1022 [inline] do_ipt_get_ctl+0x11df/0x1810 net/ipv4/netfilter/ip_tables.c:1668 nf_getsockopt+0x299/0x2c0 net/netfilter/nf_sockopt.c:116 ip_getsockopt+0x222/0x2e0 net/ipv4/ip_sockglue.c:1777 tcp_getsockopt+0x163/0x1c0 net/ipv4/tcp.c:4406 do_sock_getsockopt+0x373/0x850 net/socket.c:2374 __sys_getsockopt+0x271/0x330 net/socket.c:2403 __do_sys_getsockopt net/socket.c:2413 [inline] __se_sys_getsockopt net/socket.c:2410 [inline] __x64_sys_getsockopt+0xb5/0xd0 net/socket.c:2410 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Memory state around the buggy address: ffff88807cf9ce80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff88807cf9cf00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc >ffff88807cf9cf80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ^ ffff88807cf9d000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88807cf9d080: fb fb fb fc fc fc fc fc fc fc fc fa fb fb fb fb ==================================================================