================================================================== BUG: KASAN: slab-use-after-free in __hlist_del include/linux/list.h:982 [inline] BUG: KASAN: slab-use-after-free in hlist_del_rcu include/linux/rculist.h:560 [inline] BUG: KASAN: slab-use-after-free in __xfrm_state_delete+0x9e5/0xa30 net/xfrm/xfrm_state.c:830 Write of size 8 at addr ffff88804f448030 by task syz.1.5349/17348 CPU: 3 UID: 0 PID: 17348 Comm: syz.1.5349 Not tainted 6.16.0-syzkaller-11952-g6e64f4580381 #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0xcd/0x630 mm/kasan/report.c:482 kasan_report+0xe0/0x110 mm/kasan/report.c:595 __hlist_del include/linux/list.h:982 [inline] hlist_del_rcu include/linux/rculist.h:560 [inline] __xfrm_state_delete+0x9e5/0xa30 net/xfrm/xfrm_state.c:830 xfrm_timer_handler+0x86c/0xf10 net/xfrm/xfrm_state.c:716 __run_hrtimer kernel/time/hrtimer.c:1761 [inline] __hrtimer_run_queues+0x202/0xad0 kernel/time/hrtimer.c:1825 hrtimer_run_softirq+0x17d/0x350 kernel/time/hrtimer.c:1842 handle_softirqs+0x219/0x8e0 kernel/softirq.c:579 __do_softirq kernel/softirq.c:613 [inline] invoke_softirq kernel/softirq.c:453 [inline] __irq_exit_rcu+0x109/0x170 kernel/softirq.c:680 irq_exit_rcu+0x9/0x30 kernel/softirq.c:696 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1050 [inline] sysvec_apic_timer_interrupt+0xa4/0xc0 arch/x86/kernel/apic/apic.c:1050 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:702 RIP: 0010:__sanitizer_cov_trace_pc+0x66/0x70 kernel/kcov.c:235 Code: 82 18 16 00 00 83 f8 02 75 20 48 8b 8a 20 16 00 00 8b 92 1c 16 00 00 48 8b 01 48 83 c0 01 48 39 d0 73 07 48 89 01 48 89 34 c1 cc cc cc cc 0f 1f 44 00 00 90 90 90 90 90 90 90 90 90 90 90 90 RSP: 0018:ffffc900030a75e8 EFLAGS: 00000293 RAX: 0000000000000000 RBX: 800000006572b007 RCX: ffffffff8205c255 RDX: ffff888027fe0000 RSI: ffffffff8205c34b RDI: 0000000000000007 RBP: 000000000000002b R08: 0000000000000007 R09: 0000000000000000 R10: 800000006572b007 R11: 0000000000000000 R12: 00000000f61d5000 R13: ffff88804b965ea8 R14: dffffc0000000000 R15: 000000000000002b pte_flags arch/x86/include/asm/pgtable_types.h:481 [inline] pte_present arch/x86/include/asm/pgtable.h:968 [inline] do_zap_pte_range mm/memory.c:1681 [inline] zap_pte_range mm/memory.c:1726 [inline] zap_pmd_range mm/memory.c:1818 [inline] zap_pud_range mm/memory.c:1847 [inline] zap_p4d_range mm/memory.c:1868 [inline] unmap_page_range+0xc6b/0x42c0 mm/memory.c:1889 unmap_single_vma.constprop.0+0x153/0x240 mm/memory.c:1932 unmap_vmas+0x218/0x470 mm/memory.c:1976 exit_mmap+0x1b9/0xb90 mm/mmap.c:1280 __mmput+0x12a/0x410 kernel/fork.c:1129 mmput+0x62/0x70 kernel/fork.c:1152 exit_mm kernel/exit.c:582 [inline] do_exit+0x7c7/0x2bf0 kernel/exit.c:949 do_group_exit+0xd3/0x2a0 kernel/exit.c:1102 get_signal+0x2673/0x26d0 kernel/signal.c:3034 arch_do_signal_or_restart+0x8f/0x790 arch/x86/kernel/signal.c:337 exit_to_user_mode_loop+0x84/0x110 kernel/entry/common.c:40 exit_to_user_mode_prepare include/linux/irq-entry-common.h:225 [inline] syscall_exit_to_user_mode_work include/linux/entry-common.h:175 [inline] syscall_exit_to_user_mode include/linux/entry-common.h:210 [inline] __do_fast_syscall_32+0x2ac/0x3a0 arch/x86/entry/syscall_32.c:309 do_fast_syscall_32+0x32/0x80 arch/x86/entry/syscall_32.c:331 entry_SYSENTER_compat_after_hwframe+0x84/0x8e RIP: 0023:0xf7f68579 Code: Unable to access opcode bytes at 0xf7f6854f. RSP: 002b:00000000f548660c EFLAGS: 00000296 ORIG_RAX: 00000000000000f0 RAX: fffffffffffffe00 RBX: 00000000f7424f88 RCX: 0000000000000080 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00000000f7424f8c RBP: 0000000000000081 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 13607: 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:330 [inline] __kasan_slab_alloc+0x89/0x90 mm/kasan/common.c:356 kasan_slab_alloc include/linux/kasan.h:250 [inline] slab_post_alloc_hook mm/slub.c:4180 [inline] slab_alloc_node mm/slub.c:4229 [inline] kmem_cache_alloc_noprof+0x1cb/0x3b0 mm/slub.c:4236 xfrm_state_alloc+0x23/0x5c0 net/xfrm/xfrm_state.c:733 __find_acq_core+0xb59/0x2900 net/xfrm/xfrm_state.c:1833 xfrm_find_acq+0x7b/0xa0 net/xfrm/xfrm_state.c:2353 xfrm_alloc_userspi+0x58e/0xbb0 net/xfrm/xfrm_user.c:1863 xfrm_user_rcv_msg+0x4fe/0xb60 net/xfrm/xfrm_user.c:3501 netlink_rcv_skb+0x155/0x420 net/netlink/af_netlink.c:2552 xfrm_netlink_rcv+0x71/0x90 net/xfrm/xfrm_user.c:3523 netlink_unicast_kernel net/netlink/af_netlink.c:1320 [inline] netlink_unicast+0x5aa/0x870 net/netlink/af_netlink.c:1346 netlink_sendmsg+0x8d1/0xdd0 net/netlink/af_netlink.c:1896 sock_sendmsg_nosec net/socket.c:714 [inline] __sock_sendmsg net/socket.c:729 [inline] ____sys_sendmsg+0xa95/0xc70 net/socket.c:2614 ___sys_sendmsg+0x134/0x1d0 net/socket.c:2668 __sys_sendmsg+0x16d/0x220 net/socket.c:2700 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:83 [inline] __do_fast_syscall_32+0x7c/0x3a0 arch/x86/entry/syscall_32.c:306 do_fast_syscall_32+0x32/0x80 arch/x86/entry/syscall_32.c:331 entry_SYSENTER_compat_after_hwframe+0x84/0x8e Freed by task 2073: 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:576 poison_slab_object mm/kasan/common.c:243 [inline] __kasan_slab_free+0x60/0x70 mm/kasan/common.c:275 kasan_slab_free include/linux/kasan.h:233 [inline] slab_free_hook mm/slub.c:2417 [inline] slab_free mm/slub.c:4680 [inline] kmem_cache_free+0x2d1/0x4d0 mm/slub.c:4782 xfrm_state_free net/xfrm/xfrm_state.c:591 [inline] xfrm_state_gc_destroy net/xfrm/xfrm_state.c:618 [inline] xfrm_state_gc_task+0x50a/0x770 net/xfrm/xfrm_state.c:634 process_one_work+0x9cc/0x1b70 kernel/workqueue.c:3236 process_scheduled_works kernel/workqueue.c:3319 [inline] worker_thread+0x6c8/0xf10 kernel/workqueue.c:3400 kthread+0x3c5/0x780 kernel/kthread.c:463 ret_from_fork+0x5d7/0x6f0 arch/x86/kernel/process.c:148 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 The buggy address belongs to the object at ffff88804f448000 which belongs to the cache xfrm_state of size 928 The buggy address is located 48 bytes inside of freed 928-byte region [ffff88804f448000, ffff88804f4483a0) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x4f448 head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0x4fff00000000040(head|node=1|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 04fff00000000040 ffff88801da932c0 dead000000000122 0000000000000000 raw: 0000000000000000 00000000801e001e 00000000f5000000 0000000000000000 head: 04fff00000000040 ffff88801da932c0 dead000000000122 0000000000000000 head: 0000000000000000 00000000801e001e 00000000f5000000 0000000000000000 head: 04fff00000000003 ffffea00013d1201 00000000ffffffff 00000000ffffffff head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000008 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 3, migratetype Unmovable, gfp_mask 0x52820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 13607, tgid 13606 (syz.2.3559), ts 128063818550, free_ts 128058072920 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1c0/0x230 mm/page_alloc.c:1851 prep_new_page mm/page_alloc.c:1859 [inline] get_page_from_freelist+0x132b/0x38e0 mm/page_alloc.c:3858 __alloc_frozen_pages_noprof+0x261/0x23f0 mm/page_alloc.c:5148 alloc_pages_mpol+0x1fb/0x550 mm/mempolicy.c:2416 alloc_slab_page mm/slub.c:2487 [inline] allocate_slab mm/slub.c:2655 [inline] new_slab+0x247/0x330 mm/slub.c:2709 ___slab_alloc+0xcf2/0x1740 mm/slub.c:3891 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3981 __slab_alloc_node mm/slub.c:4056 [inline] slab_alloc_node mm/slub.c:4217 [inline] kmem_cache_alloc_noprof+0xef/0x3b0 mm/slub.c:4236 xfrm_state_alloc+0x23/0x5c0 net/xfrm/xfrm_state.c:733 __find_acq_core+0xb59/0x2900 net/xfrm/xfrm_state.c:1833 xfrm_find_acq+0x7b/0xa0 net/xfrm/xfrm_state.c:2353 xfrm_alloc_userspi+0x58e/0xbb0 net/xfrm/xfrm_user.c:1863 xfrm_user_rcv_msg+0x4fe/0xb60 net/xfrm/xfrm_user.c:3501 netlink_rcv_skb+0x155/0x420 net/netlink/af_netlink.c:2552 xfrm_netlink_rcv+0x71/0x90 net/xfrm/xfrm_user.c:3523 netlink_unicast_kernel net/netlink/af_netlink.c:1320 [inline] netlink_unicast+0x5aa/0x870 net/netlink/af_netlink.c:1346 page last free pid 13606 tgid 13606 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1395 [inline] __free_frozen_pages+0x7d5/0x10f0 mm/page_alloc.c:2895 discard_slab mm/slub.c:2753 [inline] __put_partials+0x165/0x1c0 mm/slub.c:3218 qlink_free mm/kasan/quarantine.c:163 [inline] qlist_free_all+0x4d/0x120 mm/kasan/quarantine.c:179 kasan_quarantine_reduce+0x195/0x1e0 mm/kasan/quarantine.c:286 __kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:340 kasan_slab_alloc include/linux/kasan.h:250 [inline] slab_post_alloc_hook mm/slub.c:4180 [inline] slab_alloc_node mm/slub.c:4229 [inline] __do_kmalloc_node mm/slub.c:4364 [inline] __kmalloc_noprof+0x1d4/0x510 mm/slub.c:4377 kmalloc_noprof include/linux/slab.h:909 [inline] kzalloc_noprof include/linux/slab.h:1039 [inline] tomoyo_encode2+0x100/0x3e0 security/tomoyo/realpath.c:45 tomoyo_encode+0x29/0x50 security/tomoyo/realpath.c:80 tomoyo_path_perm+0x3a5/0x460 security/tomoyo/file.c:831 tomoyo_path_symlink+0x97/0xe0 security/tomoyo/tomoyo.c:212 security_path_symlink+0x152/0x2e0 security/security.c:1984 do_symlinkat+0x10d/0x310 fs/namei.c:4754 __do_sys_symlinkat fs/namei.c:4772 [inline] __se_sys_symlinkat fs/namei.c:4769 [inline] __ia32_sys_symlinkat+0x93/0xc0 fs/namei.c:4769 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:83 [inline] __do_fast_syscall_32+0x7c/0x3a0 arch/x86/entry/syscall_32.c:306 do_fast_syscall_32+0x32/0x80 arch/x86/entry/syscall_32.c:331 entry_SYSENTER_compat_after_hwframe+0x84/0x8e Memory state around the buggy address: ffff88804f447f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88804f447f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff88804f448000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88804f448080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88804f448100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== ---------------- Code disassembly (best guess), 1 bytes skipped: 0: 18 16 sbb %dl,(%rsi) 2: 00 00 add %al,(%rax) 4: 83 f8 02 cmp $0x2,%eax 7: 75 20 jne 0x29 9: 48 8b 8a 20 16 00 00 mov 0x1620(%rdx),%rcx 10: 8b 92 1c 16 00 00 mov 0x161c(%rdx),%edx 16: 48 8b 01 mov (%rcx),%rax 19: 48 83 c0 01 add $0x1,%rax 1d: 48 39 d0 cmp %rdx,%rax 20: 73 07 jae 0x29 22: 48 89 01 mov %rax,(%rcx) 25: 48 89 34 c1 mov %rsi,(%rcx,%rax,8) * 29: c3 ret <-- trapping instruction 2a: cc int3 2b: cc int3 2c: cc int3 2d: cc int3 2e: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) 33: 90 nop 34: 90 nop 35: 90 nop 36: 90 nop 37: 90 nop 38: 90 nop 39: 90 nop 3a: 90 nop 3b: 90 nop 3c: 90 nop 3d: 90 nop 3e: 90 nop