================================================================== BUG: KASAN: slab-use-after-free in __mmap_complete mm/vma.c:2408 [inline] BUG: KASAN: slab-use-after-free in __mmap_region+0x1c38/0x202c mm/vma.c:2469 Read of size 8 at addr ff6000002f2a84f8 by task syz.3.2155/12484 CPU: 1 UID: 0 PID: 12484 Comm: syz.3.2155 Not tainted 6.13.0-rc2-syzkaller-g21f1b85c8912 #0 Hardware name: riscv-virtio,qemu (DT) Call Trace: [] dump_backtrace+0x2e/0x3c arch/riscv/kernel/stacktrace.c:130 [] show_stack+0x30/0x3c arch/riscv/kernel/stacktrace.c:136 [] __dump_stack lib/dump_stack.c:94 [inline] [] dump_stack_lvl+0x12e/0x1a6 lib/dump_stack.c:120 [] print_address_description mm/kasan/report.c:378 [inline] [] print_report+0x28e/0x5a8 mm/kasan/report.c:489 [] kasan_report+0xec/0x118 mm/kasan/report.c:602 [] __asan_report_load8_noabort+0x12/0x1a mm/kasan/report_generic.c:381 [] __mmap_complete mm/vma.c:2408 [inline] [] __mmap_region+0x1c38/0x202c mm/vma.c:2469 [] mmap_region+0x1b0/0x218 mm/mmap.c:1348 [] do_mmap+0xaa8/0xe00 mm/mmap.c:496 [] vm_mmap_pgoff+0x19e/0x310 mm/util.c:580 [] ksys_mmap_pgoff+0x2c8/0x6f8 mm/mmap.c:542 [] riscv_sys_mmap arch/riscv/kernel/sys_riscv.c:19 [inline] [] __do_sys_mmap arch/riscv/kernel/sys_riscv.c:28 [inline] [] __se_sys_mmap arch/riscv/kernel/sys_riscv.c:24 [inline] [] __riscv_sys_mmap+0xfc/0x15e arch/riscv/kernel/sys_riscv.c:24 [] syscall_handler+0x94/0x118 arch/riscv/include/asm/syscall.h:90 [] do_trap_ecall_u+0x1aa/0x216 arch/riscv/kernel/traps.c:331 [] _new_vmalloc_restore_context_a0+0xc2/0xce Allocated by task 12484: stack_trace_save+0xa0/0xd2 kernel/stacktrace.c:122 kasan_save_stack+0x3e/0x6a mm/kasan/common.c:47 kasan_save_track+0x16/0x28 mm/kasan/common.c:68 kasan_save_alloc_info+0x30/0x3e mm/kasan/generic.c:568 unpoison_slab_object mm/kasan/common.c:319 [inline] __kasan_slab_alloc+0x7c/0x82 mm/kasan/common.c:345 kasan_slab_alloc include/linux/kasan.h:250 [inline] slab_post_alloc_hook mm/slub.c:4104 [inline] slab_alloc_node mm/slub.c:4153 [inline] kmem_cache_alloc_noprof+0x108/0x3da mm/slub.c:4160 vm_area_alloc+0x32/0x1c8 kernel/fork.c:472 __mmap_new_vma mm/vma.c:2340 [inline] __mmap_region+0xb50/0x202c mm/vma.c:2456 mmap_region+0x1b0/0x218 mm/mmap.c:1348 do_mmap+0xaa8/0xe00 mm/mmap.c:496 vm_mmap_pgoff+0x19e/0x310 mm/util.c:580 ksys_mmap_pgoff+0x2c8/0x6f8 mm/mmap.c:542 riscv_sys_mmap arch/riscv/kernel/sys_riscv.c:19 [inline] __do_sys_mmap arch/riscv/kernel/sys_riscv.c:28 [inline] __se_sys_mmap arch/riscv/kernel/sys_riscv.c:24 [inline] __riscv_sys_mmap+0xfc/0x15e arch/riscv/kernel/sys_riscv.c:24 syscall_handler+0x94/0x118 arch/riscv/include/asm/syscall.h:90 do_trap_ecall_u+0x1aa/0x216 arch/riscv/kernel/traps.c:331 _new_vmalloc_restore_context_a0+0xc2/0xce Freed by task 9836: stack_trace_save+0xa0/0xd2 kernel/stacktrace.c:122 kasan_save_stack+0x3e/0x6a mm/kasan/common.c:47 kasan_save_track+0x16/0x28 mm/kasan/common.c:68 kasan_save_free_info+0x40/0x5c mm/kasan/generic.c:582 poison_slab_object mm/kasan/common.c:247 [inline] __kasan_slab_free+0x4e/0x68 mm/kasan/common.c:264 kasan_slab_free include/linux/kasan.h:233 [inline] slab_free_hook mm/slub.c:2338 [inline] slab_free mm/slub.c:4598 [inline] kmem_cache_free+0x20e/0x634 mm/slub.c:4700 __vm_area_free+0xea/0x144 kernel/fork.c:515 vm_area_free_rcu_cb+0x74/0xaa kernel/fork.c:526 rcu_do_batch kernel/rcu/tree.c:2567 [inline] rcu_core+0xa24/0x1ea0 kernel/rcu/tree.c:2823 rcu_core_si+0xc/0x14 kernel/rcu/tree.c:2840 handle_softirqs+0x4b2/0x132e kernel/softirq.c:554 __do_softirq+0x12/0x1a kernel/softirq.c:588 Last potentially related work creation: stack_trace_save+0xa0/0xd2 kernel/stacktrace.c:122 kasan_save_stack+0x3e/0x6a mm/kasan/common.c:47 __kasan_record_aux_stack+0x11a/0x166 mm/kasan/generic.c:544 kasan_record_aux_stack_noalloc+0xe/0x16 mm/kasan/generic.c:554 __call_rcu_common.constprop.0+0x9a/0x934 kernel/rcu/tree.c:3086 call_rcu+0xc/0x14 kernel/rcu/tree.c:3190 vm_area_free+0x26/0x30 kernel/fork.c:533 vma_complete+0x672/0xa22 mm/vma.c:310 commit_merge+0x90e/0xda8 mm/vma.c:674 vma_merge_existing_range+0x83e/0x1b56 mm/vma.c:897 __mmap_region+0x6ac/0x202c mm/vma.c:2466 mmap_region+0x1b0/0x218 mm/mmap.c:1348 do_mmap+0xaa8/0xe00 mm/mmap.c:496 vm_mmap_pgoff+0x19e/0x310 mm/util.c:580 ksys_mmap_pgoff+0x2c8/0x6f8 mm/mmap.c:542 riscv_sys_mmap arch/riscv/kernel/sys_riscv.c:19 [inline] __do_sys_mmap arch/riscv/kernel/sys_riscv.c:28 [inline] __se_sys_mmap arch/riscv/kernel/sys_riscv.c:24 [inline] __riscv_sys_mmap+0xfc/0x15e arch/riscv/kernel/sys_riscv.c:24 syscall_handler+0x94/0x118 arch/riscv/include/asm/syscall.h:90 do_trap_ecall_u+0x1aa/0x216 arch/riscv/kernel/traps.c:331 _new_vmalloc_restore_context_a0+0xc2/0xce The buggy address belongs to the object at ff6000002f2a84d8 which belongs to the cache vm_area_struct of size 184 The buggy address is located 32 bytes inside of freed 184-byte region [ff6000002f2a84d8, ff6000002f2a8590) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0xaf2a8 memcg:ff600000315b8c01 flags: 0xffe000000000000(node=0|zone=0|lastcpupid=0x7ff) page_type: f5(slab) raw: 0ffe000000000000 ff60000011e883c0 ff1c00000073df80 0000000000000002 raw: 0000000000000000 0000000080100010 00000001f5000000 ff600000315b8c01 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x52cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 12233, tgid 12233 (rm), ts 10540366515200, free_ts 10540139768500 __set_page_owner+0xa2/0x70c mm/page_owner.c:320 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0xf0/0x1e8 mm/page_alloc.c:1556 prep_new_page mm/page_alloc.c:1564 [inline] get_page_from_freelist+0xdb2/0x2c12 mm/page_alloc.c:3474 __alloc_pages_noprof+0x1e8/0x1fc0 mm/page_alloc.c:4751 alloc_pages_mpol_noprof+0xf8/0x488 mm/mempolicy.c:2269 alloc_pages_noprof+0x174/0x2f0 mm/mempolicy.c:2348 alloc_slab_page mm/slub.c:2408 [inline] allocate_slab mm/slub.c:2574 [inline] new_slab+0x2b6/0x40c mm/slub.c:2627 ___slab_alloc+0x9ca/0x10e8 mm/slub.c:3815 __slab_alloc.constprop.0+0x60/0xb0 mm/slub.c:3905 __slab_alloc_node mm/slub.c:3980 [inline] slab_alloc_node mm/slub.c:4141 [inline] kmem_cache_alloc_noprof+0xd2/0x3da mm/slub.c:4160 vm_area_alloc+0x32/0x1c8 kernel/fork.c:472 __mmap_new_vma mm/vma.c:2340 [inline] __mmap_region+0xb50/0x202c mm/vma.c:2456 mmap_region+0xe8/0x218 mm/mmap.c:1348 do_mmap+0xaa8/0xe00 mm/mmap.c:496 vm_mmap_pgoff+0x19e/0x310 mm/util.c:580 vm_mmap+0x84/0xac mm/util.c:599 page last free pid 12233 tgid 12233 stack trace: __reset_page_owner+0x8c/0x400 mm/page_owner.c:297 reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1127 [inline] free_unref_page+0x61e/0x11d6 mm/page_alloc.c:2657 __folio_put+0x1bc/0x27e mm/swap.c:112 folio_put include/linux/mm.h:1488 [inline] free_page_and_swap_cache+0x1a8/0x1e2 mm/swap_state.c:308 __tlb_remove_table arch/riscv/include/asm/tlb.h:26 [inline] __tlb_remove_table_free mm/mmu_gather.c:227 [inline] tlb_remove_table_rcu+0x86/0xee mm/mmu_gather.c:282 rcu_do_batch kernel/rcu/tree.c:2567 [inline] rcu_core+0xa24/0x1ea0 kernel/rcu/tree.c:2823 rcu_core_si+0xc/0x14 kernel/rcu/tree.c:2840 handle_softirqs+0x4b2/0x132e kernel/softirq.c:554 __do_softirq kernel/softirq.c:588 [inline] invoke_softirq kernel/softirq.c:428 [inline] __irq_exit_rcu+0x18c/0x550 kernel/softirq.c:655 irq_exit_rcu+0x10/0xf8 kernel/softirq.c:671 handle_riscv_irq+0x40/0x4c arch/riscv/kernel/traps.c:378 call_on_irq_stack+0x32/0x40 arch/riscv/kernel/entry.S:355 Memory state around the buggy address: ff6000002f2a8380: fb fb fb fb fc fc fc fc fc fc fc fc fa fb fb fb ff6000002f2a8400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ff6000002f2a8480: fb fb fb fc fc fc fc fc fc fc fc fa fb fb fb fb ^ ff6000002f2a8500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ff6000002f2a8580: fb fb fc fc fc fc fc fc fc fc 00 00 00 00 00 00 ==================================================================