================================================================== 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 ffff888037d10d20 by task syz-executor.0/15280 CPU: 1 PID: 15280 Comm: syz-executor.0 Not tainted 6.8.0-rc2-syzkaller-00397-g56897d51886f #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:__sanitizer_cov_trace_pc+0x0/0x70 kernel/kcov.c:200 Code: 89 fb e8 23 00 00 00 48 8b 3d b4 9a 1a 0c 48 89 de 5b e9 43 ca 56 00 0f 1f 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 0f 1e fa 48 8b 04 24 65 48 8b 0d c0 57 70 7e 65 8b 15 c1 57 70 RSP: 0018:ffffc9000438f0a0 EFLAGS: 00000202 RAX: 1ffff92000871e01 RBX: ffffffff90a18698 RCX: dffffc0000000000 RDX: ffffc9000a4a5000 RSI: 000000000003ffff RDI: 0000000000040000 RBP: ffffc9000438f180 R08: ffffffff81407b2b R09: ffffffff814066c0 R10: 0000000000000003 R11: ffff888034c73b80 R12: ffffc9000438ff50 R13: dffffc0000000000 R14: ffffc9000438f1d0 R15: 1ffff92000871e30 unwind_next_frame+0x1ac2/0x29e0 arch/x86/kernel/unwind_orc.c:648 arch_stack_walk+0x150/0x1b0 arch/x86/kernel/stacktrace.c:25 stack_trace_save+0x117/0x1d0 kernel/stacktrace.c:122 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 kernfs_put+0x1c4/0x420 fs/kernfs/dir.c:560 kernfs_remove_by_name_ns+0xe4/0x160 fs/kernfs/dir.c:1686 kernfs_remove_by_name include/linux/kernfs.h:623 [inline] remove_files fs/sysfs/group.c:28 [inline] sysfs_remove_group+0xfe/0x2b0 fs/sysfs/group.c:292 sysfs_remove_groups+0x54/0xb0 fs/sysfs/group.c:316 destroy_port drivers/infiniband/core/sysfs.c:1289 [inline] ib_free_port_attrs+0x26a/0x3e0 drivers/infiniband/core/sysfs.c:1419 remove_one_compat_dev drivers/infiniband/core/device.c:1002 [inline] rdma_dev_exit_net+0x1f3/0x350 drivers/infiniband/core/device.c:1140 ops_exit_list net/core/net_namespace.c:170 [inline] setup_net+0x8d5/0xbc0 net/core/net_namespace.c:362 copy_net_ns+0x4e3/0x7b0 net/core/net_namespace.c:495 create_new_namespaces+0x425/0x7b0 kernel/nsproxy.c:110 copy_namespaces+0x41a/0x490 kernel/nsproxy.c:179 copy_process+0x1e71/0x3fc0 kernel/fork.c:2500 kernel_clone+0x21d/0x8d0 kernel/fork.c:2902 __do_sys_clone kernel/fork.c:3045 [inline] __se_sys_clone kernel/fork.c:3029 [inline] __x64_sys_clone+0x258/0x2a0 kernel/fork.c:3029 do_syscall_64+0xfb/0x240 entry_SYSCALL_64_after_hwframe+0x6f/0x77 RIP: 0033:0x7f232aa7dda9 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:00007f2329dde078 EFLAGS: 00000202 ORIG_RAX: 0000000000000038 RAX: ffffffffffffffda RBX: 00007f232abac120 RCX: 00007f232aa7dda9 RDX: 0000000020001540 RSI: 0000000020001530 RDI: 0000000040005080 RBP: 00007f232aaca47a R08: 0000000020001700 R09: 0000000020001700 R10: 0000000020001580 R11: 0000000000000202 R12: 0000000000000000 R13: 000000000000006e R14: 00007f232abac120 R15: 00007ffea9429438 Allocated by task 13912: 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 30459: 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 ffff888037d10d20 which belongs to the cache kmalloc-8 of size 8 The buggy address is located 0 bytes inside of freed 8-byte region [ffff888037d10d20, ffff888037d10d28) The buggy address belongs to the physical page: page:ffffea0000df4400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x37d10 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 9106, tgid 9104 (syz-executor.3), ts 2392678325262, free_ts 2391565408754 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_track_caller+0x2d1/0x4e0 mm/slub.c:4001 kstrdup+0x3a/0x80 mm/util.c:62 __kernfs_new_node+0x9d/0x880 fs/kernfs/dir.c:611 kernfs_new_node+0x13a/0x240 fs/kernfs/dir.c:691 __kernfs_create_file+0x49/0x2f0 fs/kernfs/file.c:1025 sysfs_add_file_mode_ns+0x24a/0x310 fs/sysfs/file.c:307 create_files fs/sysfs/group.c:64 [inline] internal_create_group+0x4f4/0xf20 fs/sysfs/group.c:152 internal_create_groups fs/sysfs/group.c:192 [inline] sysfs_create_groups+0x56/0x120 fs/sysfs/group.c:218 setup_gid_attrs drivers/infiniband/core/sysfs.c:1173 [inline] ib_setup_port_attrs+0x16a4/0x2440 drivers/infiniband/core/sysfs.c:1450 add_one_compat_dev+0x51a/0x710 drivers/infiniband/core/device.c:969 page last free pid 9137 tgid 9136 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 tlb_batch_list_free mm/mmu_gather.c:114 [inline] tlb_finish_mmu+0x11f/0x200 mm/mmu_gather.c:395 unmap_region+0x2df/0x350 mm/mmap.c:2311 do_vmi_align_munmap+0x11bf/0x1930 mm/mmap.c:2627 do_vmi_munmap+0x24d/0x2d0 mm/mmap.c:2695 __vm_munmap+0x20b/0x480 mm/mmap.c:2982 __do_sys_munmap mm/mmap.c:2999 [inline] __se_sys_munmap mm/mmap.c:2996 [inline] __x64_sys_munmap+0x69/0x80 mm/mmap.c:2996 do_syscall_64+0xfb/0x240 entry_SYSCALL_64_after_hwframe+0x6f/0x77 Memory state around the buggy address: ffff888037d10c00: 05 fc fc fc fc fc fc fc fc fc fc fc 05 fc fc fc ffff888037d10c80: fc fc fc fc fc fc fc fc 04 fc fc fc fc fc fc fc >ffff888037d10d00: fc fc fc fc fa fc fc fc fc fc fc fc fc fc fc fc ^ ffff888037d10d80: fa fc fc fc fc fc fc fc fc fc fc fc 05 fc fc fc ffff888037d10e00: fc fc fc fc fc fc fc fc 04 fc fc fc fc fc fc fc ================================================================== ---------------- Code disassembly (best guess): 0: 89 fb mov %edi,%ebx 2: e8 23 00 00 00 call 0x2a 7: 48 8b 3d b4 9a 1a 0c mov 0xc1a9ab4(%rip),%rdi # 0xc1a9ac2 e: 48 89 de mov %rbx,%rsi 11: 5b pop %rbx 12: e9 43 ca 56 00 jmp 0x56ca5a 17: 0f 1f 00 nopl (%rax) 1a: 90 nop 1b: 90 nop 1c: 90 nop 1d: 90 nop 1e: 90 nop 1f: 90 nop 20: 90 nop 21: 90 nop 22: 90 nop 23: 90 nop 24: 90 nop 25: 90 nop 26: 90 nop 27: 90 nop 28: 90 nop 29: 90 nop * 2a: f3 0f 1e fa endbr64 <-- trapping instruction 2e: 48 8b 04 24 mov (%rsp),%rax 32: 65 48 8b 0d c0 57 70 mov %gs:0x7e7057c0(%rip),%rcx # 0x7e7057fa 39: 7e 3a: 65 gs 3b: 8b .byte 0x8b 3c: 15 .byte 0x15 3d: c1 .byte 0xc1 3e: 57 push %rdi 3f: 70 .byte 0x70