================================================================== BUG: KASAN: slab-use-after-free in instrument_atomic_read include/linux/instrumented.h:68 [inline] BUG: KASAN: slab-use-after-free in _test_bit include/asm-generic/bitops/instrumented-non-atomic.h:141 [inline] BUG: KASAN: slab-use-after-free in bitmap_port_gc_test net/netfilter/ipset/ip_set_bitmap_port.c:67 [inline] BUG: KASAN: slab-use-after-free in bitmap_port_gc+0x146/0x4c0 net/netfilter/ipset/ip_set_bitmap_gen.h:277 Read of size 8 at addr ffff88807e059840 by task syz-executor.4/8172 CPU: 0 PID: 8172 Comm: syz-executor.4 Not tainted 6.8.0-rc3-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e7/0x2e0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:377 [inline] print_report+0x167/0x540 mm/kasan/report.c:488 kasan_report+0x142/0x180 mm/kasan/report.c:601 kasan_check_range+0x282/0x290 mm/kasan/generic.c:189 instrument_atomic_read include/linux/instrumented.h:68 [inline] _test_bit include/asm-generic/bitops/instrumented-non-atomic.h:141 [inline] bitmap_port_gc_test net/netfilter/ipset/ip_set_bitmap_port.c:67 [inline] bitmap_port_gc+0x146/0x4c0 net/netfilter/ipset/ip_set_bitmap_gen.h:277 call_timer_fn+0x180/0x600 kernel/time/timer.c:1700 expire_timers kernel/time/timer.c:1751 [inline] __run_timers+0x621/0x830 kernel/time/timer.c:2038 run_timer_softirq+0x67/0xf0 kernel/time/timer.c:2051 __do_softirq+0x2bd/0x942 kernel/softirq.c:553 invoke_softirq kernel/softirq.c:427 [inline] __irq_exit_rcu+0xf1/0x1c0 kernel/softirq.c:632 irq_exit_rcu+0x9/0x30 kernel/softirq.c:644 sysvec_apic_timer_interrupt+0x97/0xb0 arch/x86/kernel/apic/apic.c:1076 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:649 RIP: 0010:__raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:152 [inline] RIP: 0010:_raw_spin_unlock_irqrestore+0xd8/0x140 kernel/locking/spinlock.c:194 Code: 9c 8f 44 24 20 42 80 3c 23 00 74 08 4c 89 f7 e8 ae 74 84 f6 f6 44 24 21 02 75 52 41 f7 c7 00 02 00 00 74 01 fb bf 01 00 00 00 73 3a f3 f5 65 8b 05 04 b1 92 74 85 c0 74 43 48 c7 04 24 0e 36 RSP: 0018:ffffc90004027600 EFLAGS: 00000206 RAX: 2b5f96881c6e7500 RBX: 1ffff92000804ec4 RCX: ffffffff817183ea RDX: dffffc0000000000 RSI: ffffffff8baab540 RDI: 0000000000000001 RBP: ffffc90004027690 R08: ffffffff92c894c7 R09: 1ffffffff2591298 R10: dffffc0000000000 R11: fffffbfff2591299 R12: dffffc0000000000 R13: 1ffff92000804ec0 R14: ffffc90004027620 R15: 0000000000000246 spin_unlock_irqrestore include/linux/spinlock.h:406 [inline] __wake_up_common_lock+0x18c/0x1e0 kernel/sched/wait.c:108 __unix_dgram_recvmsg+0x602/0x12c0 net/unix/af_unix.c:2408 sock_recvmsg_nosec+0x190/0x1d0 net/socket.c:1046 ____sys_recvmsg+0x3c0/0x470 net/socket.c:2801 ___sys_recvmsg net/socket.c:2845 [inline] do_recvmmsg+0x474/0xae0 net/socket.c:2939 __sys_recvmmsg net/socket.c:3018 [inline] __do_sys_recvmmsg net/socket.c:3041 [inline] __se_sys_recvmmsg net/socket.c:3034 [inline] __x64_sys_recvmmsg+0x199/0x250 net/socket.c:3034 do_syscall_64+0xfb/0x240 entry_SYSCALL_64_after_hwframe+0x6f/0x77 RIP: 0033:0x7f0f47e7dda9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 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 b0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f0f48c660c8 EFLAGS: 00000246 ORIG_RAX: 000000000000012b RAX: ffffffffffffffda RBX: 00007f0f47fac050 RCX: 00007f0f47e7dda9 RDX: 0000000000010106 RSI: 00000000200000c0 RDI: 0000000000000005 RBP: 00007f0f47eca47a R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000000 R13: 000000000000006e R14: 00007f0f47fac050 R15: 00007ffc87865b58 Allocated by task 6181: 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:372 [inline] __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:389 kasan_kmalloc include/linux/kasan.h:211 [inline] __do_kmalloc_node mm/slub.c:3981 [inline] __kmalloc+0x22e/0x490 mm/slub.c:3994 init_map_port net/netfilter/ipset/ip_set_bitmap_port.c:234 [inline] bitmap_port_create+0x324/0x7c0 net/netfilter/ipset/ip_set_bitmap_port.c:276 ip_set_create+0xa5e/0x1780 net/netfilter/ipset/ip_set_core.c:1103 nfnetlink_rcv_msg+0xbee/0x1190 net/netfilter/nfnetlink.c:302 netlink_rcv_skb+0x1e5/0x430 net/netlink/af_netlink.c:2543 nfnetlink_rcv+0x294/0x2650 net/netfilter/nfnetlink.c:659 netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline] netlink_unicast+0x7ec/0x980 net/netlink/af_netlink.c:1367 netlink_sendmsg+0xa3b/0xd70 net/netlink/af_netlink.c:1908 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0x223/0x270 net/socket.c:745 ____sys_sendmsg+0x525/0x7d0 net/socket.c:2584 ___sys_sendmsg net/socket.c:2638 [inline] __sys_sendmsg+0x2b0/0x3a0 net/socket.c:2667 do_syscall_64+0xfb/0x240 entry_SYSCALL_64_after_hwframe+0x6f/0x77 Freed by task 2455: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x4e/0x60 mm/kasan/generic.c:640 poison_slab_object+0xa6/0xe0 mm/kasan/common.c:241 __kasan_slab_free+0x34/0x70 mm/kasan/common.c:257 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2121 [inline] slab_free mm/slub.c:4299 [inline] kfree+0x14a/0x380 mm/slub.c:4409 bitmap_port_destroy+0x300/0x390 net/netfilter/ipset/ip_set_bitmap_gen.h:65 ip_set_destroy_set net/netfilter/ipset/ip_set_core.c:1180 [inline] ip_set_net_exit+0x252/0x470 net/netfilter/ipset/ip_set_core.c:2381 ops_exit_list net/core/net_namespace.c:170 [inline] cleanup_net+0x6dc/0xb90 net/core/net_namespace.c:618 process_one_work kernel/workqueue.c:2633 [inline] process_scheduled_works+0x915/0x1420 kernel/workqueue.c:2706 worker_thread+0xa5f/0x1000 kernel/workqueue.c:2787 kthread+0x2f1/0x390 kernel/kthread.c:388 ret_from_fork+0x4d/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:242 The buggy address belongs to the object at ffff88807e059840 which belongs to the cache kmalloc-8 of size 8 The buggy address is located 0 bytes inside of freed 8-byte region [ffff88807e059840, ffff88807e059848) The buggy address belongs to the physical page: page:ffffea0001f81640 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7e059 anon flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000800 ffff888014c41280 0000000000000000 dead000000000001 raw: 0000000000000000 00000000002a002a 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 5437, tgid 5437 (syz-executor.5), ts 165976366129, free_ts 165976221019 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x1ea/0x210 mm/page_alloc.c:1533 prep_new_page mm/page_alloc.c:1540 [inline] get_page_from_freelist+0x33ea/0x3580 mm/page_alloc.c:3311 __alloc_pages+0x255/0x680 mm/page_alloc.c:4567 __alloc_pages_node include/linux/gfp.h:238 [inline] alloc_pages_node include/linux/gfp.h:261 [inline] alloc_slab_page+0x5f/0x160 mm/slub.c:2190 allocate_slab mm/slub.c:2354 [inline] new_slab+0x84/0x2f0 mm/slub.c:2407 ___slab_alloc+0xd17/0x13e0 mm/slub.c:3540 __slab_alloc mm/slub.c:3625 [inline] __slab_alloc_node mm/slub.c:3678 [inline] slab_alloc_node mm/slub.c:3850 [inline] __do_kmalloc_node mm/slub.c:3980 [inline] __kmalloc_node+0x2d6/0x4e0 mm/slub.c:3988 kmalloc_node include/linux/slab.h:610 [inline] __vmalloc_area_node mm/vmalloc.c:3125 [inline] __vmalloc_node_range+0x5f9/0x14a0 mm/vmalloc.c:3320 __vmalloc_node mm/vmalloc.c:3385 [inline] vzalloc+0x79/0x90 mm/vmalloc.c:3458 alloc_counters+0xd7/0x760 net/ipv4/netfilter/ip_tables.c:799 copy_entries_to_user net/ipv4/netfilter/ip_tables.c:821 [inline] get_entries net/ipv4/netfilter/ip_tables.c:1022 [inline] do_ipt_get_ctl+0xeca/0x1810 net/ipv4/netfilter/ip_tables.c:1660 nf_getsockopt+0x29b/0x2c0 net/netfilter/nf_sockopt.c:116 ip_getsockopt+0x222/0x2e0 net/ipv4/ip_sockglue.c:1770 tcp_getsockopt+0x165/0x1c0 net/ipv4/tcp.c:4372 do_sock_getsockopt+0x375/0x850 net/socket.c:2373 __sys_getsockopt+0x270/0x330 net/socket.c:2402 page last free pid 5437 tgid 5437 stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1140 [inline] free_unref_page_prepare+0x968/0xa90 mm/page_alloc.c:2346 free_unref_page+0x37/0x3f0 mm/page_alloc.c:2486 vfree+0x186/0x2e0 mm/vmalloc.c:2842 __do_replace+0x86c/0xa40 net/ipv4/netfilter/ip_tables.c:1090 do_replace net/ipv4/netfilter/ip_tables.c:1137 [inline] do_ipt_set_ctl+0x287c/0x3dd0 net/ipv4/netfilter/ip_tables.c:1627 nf_setsockopt+0x297/0x2c0 net/netfilter/nf_sockopt.c:101 do_sock_setsockopt+0x3b1/0x720 net/socket.c:2311 __sys_setsockopt+0x1ad/0x250 net/socket.c:2334 __do_sys_setsockopt net/socket.c:2343 [inline] __se_sys_setsockopt net/socket.c:2340 [inline] __x64_sys_setsockopt+0xb5/0xd0 net/socket.c:2340 do_syscall_64+0xfb/0x240 entry_SYSCALL_64_after_hwframe+0x6f/0x77 Memory state around the buggy address: ffff88807e059700: fc fc fc fc 00 fc fc fc fc fc fc fc fc fc fc fc ffff88807e059780: fa fc fc fc fc fc fc fc fc fc fc fc fa fc fc fc >ffff88807e059800: fc fc fc fc fc fc fc fc fa fc fc fc fc fc fc fc ^ ffff88807e059880: fc fc fc fc fa fc fc fc fc fc fc fc fc fc fc fc ffff88807e059900: fa fc fc fc fc fc fc fc fc fc fc fc fa fc fc fc ================================================================== ---------------- Code disassembly (best guess): 0: 9c pushf 1: 8f 44 24 20 pop 0x20(%rsp) 5: 42 80 3c 23 00 cmpb $0x0,(%rbx,%r12,1) a: 74 08 je 0x14 c: 4c 89 f7 mov %r14,%rdi f: e8 ae 74 84 f6 call 0xf68474c2 14: f6 44 24 21 02 testb $0x2,0x21(%rsp) 19: 75 52 jne 0x6d 1b: 41 f7 c7 00 02 00 00 test $0x200,%r15d 22: 74 01 je 0x25 24: fb sti 25: bf 01 00 00 00 mov $0x1,%edi * 2a: e8 73 3a f3 f5 call 0xf5f33aa2 <-- trapping instruction 2f: 65 8b 05 04 b1 92 74 mov %gs:0x7492b104(%rip),%eax # 0x7492b13a 36: 85 c0 test %eax,%eax 38: 74 43 je 0x7d 3a: 48 rex.W 3b: c7 .byte 0xc7 3c: 04 24 add $0x24,%al 3e: 0e (bad) 3f: 36 ss