BUG: KASAN: use-after-free in mas_safe_min lib/maple_tree.c:721 [inline] BUG: KASAN: use-after-free in mas_next_nentry+0x9e4/0xab0 lib/maple_tree.c:4662 Read of size 8 at addr ffff8880222c9a20 by task syz-executor.3/5628 CPU: 0 PID: 5628 Comm: syz-executor.3 Not tainted 6.0.0-syzkaller-12255-g2df76606db9d #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:284 [inline] print_report+0x15e/0x461 mm/kasan/report.c:395 kasan_report+0xbb/0x1f0 mm/kasan/report.c:495 mas_safe_min lib/maple_tree.c:721 [inline] mas_next_nentry+0x9e4/0xab0 lib/maple_tree.c:4662 mas_next_entry lib/maple_tree.c:4757 [inline] mas_next+0x1fb/0xc90 lib/maple_tree.c:5868 userfaultfd_unregister fs/userfaultfd.c:1657 [inline] userfaultfd_ioctl+0x33c3/0x4200 fs/userfaultfd.c:2005 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f83dae8b5a9 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 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f83dc03a168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f83dafabf80 RCX: 00007f83dae8b5a9 RDX: 0000000020000140 RSI: 000000008010aa01 RDI: 0000000000000003 RBP: 00007f83daee6580 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffeaf7b9e4f R14: 00007f83dc03a300 R15: 0000000000022000 Allocated by task 3705: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:45 kasan_set_track+0x21/0x30 mm/kasan/common.c:52 __kasan_slab_alloc+0x7b/0x80 mm/kasan/common.c:325 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook mm/slab.h:737 [inline] kmem_cache_alloc_bulk+0x2fb/0x480 mm/slab.c:3509 mt_alloc_bulk lib/maple_tree.c:157 [inline] mas_alloc_nodes+0x309/0x810 lib/maple_tree.c:1256 mas_node_count_gfp+0x106/0x140 lib/maple_tree.c:1316 mas_node_count lib/maple_tree.c:1330 [inline] mas_expected_entries+0x113/0x200 lib/maple_tree.c:5822 dup_mmap+0x4ca/0x10b0 kernel/fork.c:613 dup_mm+0x91/0x370 kernel/fork.c:1526 copy_mm kernel/fork.c:1575 [inline] copy_process+0x3bc6/0x7190 kernel/fork.c:2253 kernel_clone+0xe7/0x980 kernel/fork.c:2671 __do_sys_clone+0xba/0x100 kernel/fork.c:2812 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 5628: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:45 kasan_set_track+0x21/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:511 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x13b/0x1a0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:177 [inline] __cache_free mm/slab.c:3389 [inline] kmem_cache_free_bulk+0xf3/0x460 mm/slab.c:3644 mt_free_bulk lib/maple_tree.c:163 [inline] mas_destroy+0x394/0x5c0 lib/maple_tree.c:5769 mas_store_prealloc+0xec/0x150 lib/maple_tree.c:5704 __vma_adjust+0xc47/0x1a70 mm/mmap.c:783 vma_adjust include/linux/mm.h:2663 [inline] __split_vma+0x4b0/0x5c0 mm/mmap.c:2236 split_vma+0x9f/0xe0 mm/mmap.c:2272 userfaultfd_unregister fs/userfaultfd.c:1636 [inline] userfaultfd_ioctl+0x3855/0x4200 fs/userfaultfd.c:2005 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff8880222c9a00 which belongs to the cache maple_node of size 256 The buggy address is located 32 bytes inside of 256-byte region [ffff8880222c9a00, ffff8880222c9b00) The buggy address belongs to the physical page: page:ffffea000088b240 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880222c9400 pfn:0x222c9 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffffea00007b7188 ffffea00007e2a08 ffff88801186f100 raw: ffff8880222c9400 ffff8880222c9000 0000000100000006 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 0x2420c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_THISNODE), pid 1, tgid 1 (init), ts 33260541623, free_ts 32356347849 prep_new_page mm/page_alloc.c:2538 [inline] get_page_from_freelist+0x10b5/0x2d50 mm/page_alloc.c:4287 __alloc_pages+0x1c7/0x5a0 mm/page_alloc.c:5554 __alloc_pages_node include/linux/gfp.h:223 [inline] kmem_getpages mm/slab.c:1363 [inline] cache_grow_begin+0x75/0x360 mm/slab.c:2570 cache_alloc_refill+0x27f/0x380 mm/slab.c:2943 ____cache_alloc mm/slab.c:3019 [inline] ____cache_alloc mm/slab.c:3002 [inline] __do_cache_alloc mm/slab.c:3202 [inline] kmem_cache_alloc_bulk+0x34b/0x480 mm/slab.c:3495 mt_alloc_bulk lib/maple_tree.c:157 [inline] mas_alloc_nodes+0x309/0x810 lib/maple_tree.c:1256 mas_node_count_gfp lib/maple_tree.c:1316 [inline] mas_preallocate+0x1b7/0x360 lib/maple_tree.c:5719 __vma_adjust+0x181/0x1a70 mm/mmap.c:715 vma_adjust include/linux/mm.h:2663 [inline] __split_vma+0x295/0x5c0 mm/mmap.c:2239 split_vma+0x9f/0xe0 mm/mmap.c:2272 mprotect_fixup+0x746/0x960 mm/mprotect.c:623 do_mprotect_pkey+0x6fd/0xa70 mm/mprotect.c:792 __do_sys_mprotect mm/mprotect.c:819 [inline] __se_sys_mprotect mm/mprotect.c:816 [inline] __x64_sys_mprotect+0x74/0xb0 mm/mprotect.c:816 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1458 [inline] free_pcp_prepare+0x65c/0xd90 mm/page_alloc.c:1508 free_unref_page_prepare mm/page_alloc.c:3386 [inline] free_unref_page+0x19/0x4d0 mm/page_alloc.c:3482 kasan_depopulate_vmalloc_pte+0x5c/0x70 mm/kasan/shadow.c:372 apply_to_pte_range mm/memory.c:2640 [inline] apply_to_pmd_range mm/memory.c:2684 [inline] apply_to_pud_range mm/memory.c:2720 [inline] apply_to_p4d_range mm/memory.c:2756 [inline] __apply_to_page_range+0x68c/0x1030 mm/memory.c:2790 kasan_release_vmalloc+0xa7/0xc0 mm/kasan/shadow.c:486 __purge_vmap_area_lazy+0x885/0x1c50 mm/vmalloc.c:1770 _vm_unmap_aliases.part.0+0x420/0x550 mm/vmalloc.c:2173 _vm_unmap_aliases mm/vmalloc.c:2147 [inline] vm_unmap_aliases+0x45/0x50 mm/vmalloc.c:2196 change_page_attr_set_clr+0x241/0x500 arch/x86/mm/pat/set_memory.c:1777 change_page_attr_set arch/x86/mm/pat/set_memory.c:1827 [inline] set_memory_nx+0xb2/0x110 arch/x86/mm/pat/set_memory.c:2020 free_init_pages+0x73/0xc0 arch/x86/mm/init.c:908 kernel_init+0x2e/0x1d0 init/main.c:1528 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306 Memory state around the buggy address: ffff8880222c9900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff8880222c9980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff8880222c9a00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8880222c9a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880222c9b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================