================================================================== 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 ffff88807846fe20 by task syz-executor.4/2754 CPU: 0 PID: 2754 Comm: syz-executor.4 Not tainted 6.1.0-rc1-syzkaller-00249-g4da34b7d175d #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/11/2022 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/0x45d 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 compat_ptr_ioctl+0x67/0x90 fs/ioctl.c:906 __do_compat_sys_ioctl+0x1c7/0x290 fs/ioctl.c:968 do_syscall_32_irqs_on arch/x86/entry/common.c:112 [inline] __do_fast_syscall_32+0x65/0xf0 arch/x86/entry/common.c:178 do_fast_syscall_32+0x2f/0x70 arch/x86/entry/common.c:203 entry_SYSENTER_compat_after_hwframe+0x70/0x82 RIP: 0023:0xf7fe4549 Code: 03 74 c0 01 10 05 03 74 b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 03 74 d8 01 00 00 00 00 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 8d b4 26 00 00 00 00 8d b4 26 00 00 00 00 RSP: 002b:00000000f7fdf5cc EFLAGS: 00000296 ORIG_RAX: 0000000000000036 RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 000000008010aa01 RDX: 0000000020000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000296 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 2754: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:45 kasan_set_track+0x21/0x30 mm/kasan/common.c:52 __kasan_slab_alloc+0x7e/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+0x3e9/0x830 mm/slub.c:3854 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+0x18e/0x1ae0 mm/mmap.c:716 vma_adjust include/linux/mm.h:2663 [inline] __split_vma+0x4b0/0x5c0 mm/mmap.c:2237 split_vma+0x9f/0xe0 mm/mmap.c:2273 userfaultfd_register fs/userfaultfd.c:1447 [inline] userfaultfd_ioctl+0x3a4e/0x4200 fs/userfaultfd.c:2002 compat_ptr_ioctl+0x67/0x90 fs/ioctl.c:906 __do_compat_sys_ioctl+0x1c7/0x290 fs/ioctl.c:968 do_syscall_32_irqs_on arch/x86/entry/common.c:112 [inline] __do_fast_syscall_32+0x65/0xf0 arch/x86/entry/common.c:178 do_fast_syscall_32+0x2f/0x70 arch/x86/entry/common.c:203 entry_SYSENTER_compat_after_hwframe+0x70/0x82 Freed by task 2754: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:45 kasan_set_track+0x21/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x2a/0x40 mm/kasan/generic.c:511 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x160/0x1c0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:177 [inline] slab_free_hook mm/slub.c:1724 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1750 slab_free mm/slub.c:3661 [inline] kmem_cache_free_bulk.part.0+0x205/0x780 mm/slub.c:3779 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+0xc66/0x1ae0 mm/mmap.c:784 vma_adjust include/linux/mm.h:2663 [inline] __split_vma+0x4b0/0x5c0 mm/mmap.c:2237 split_vma+0x9f/0xe0 mm/mmap.c:2273 userfaultfd_unregister fs/userfaultfd.c:1636 [inline] userfaultfd_ioctl+0x3855/0x4200 fs/userfaultfd.c:2005 compat_ptr_ioctl+0x67/0x90 fs/ioctl.c:906 __do_compat_sys_ioctl+0x1c7/0x290 fs/ioctl.c:968 do_syscall_32_irqs_on arch/x86/entry/common.c:112 [inline] __do_fast_syscall_32+0x65/0xf0 arch/x86/entry/common.c:178 do_fast_syscall_32+0x2f/0x70 arch/x86/entry/common.c:203 entry_SYSENTER_compat_after_hwframe+0x70/0x82 The buggy address belongs to the object at ffff88807846fe00 which belongs to the cache maple_node of size 256 The buggy address is located 32 bytes inside of 256-byte region [ffff88807846fe00, ffff88807846ff00) The buggy address belongs to the physical page: page:ffffea0001e11b80 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7846e head:ffffea0001e11b80 order:1 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 ffffea000159e680 dead000000000004 ffff88801184fdc0 raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 1, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 1333, tgid 1332 (syz-executor.5), ts 744817415354, free_ts 743275620530 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+0x1a6/0x270 mm/mempolicy.c:2285 alloc_slab_page mm/slub.c:1794 [inline] allocate_slab+0x213/0x300 mm/slub.c:1939 new_slab mm/slub.c:1992 [inline] ___slab_alloc+0xa91/0x1400 mm/slub.c:3180 kmem_cache_alloc_bulk+0x28b/0x830 mm/slub.c:3830 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+0x18e/0x1ae0 mm/mmap.c:716 vma_adjust include/linux/mm.h:2663 [inline] __split_vma+0x295/0x5c0 mm/mmap.c:2240 do_mas_align_munmap+0x27e/0xee0 mm/mmap.c:2341 do_mas_munmap+0x26a/0x2b0 mm/mmap.c:2502 mmap_region+0x219/0x1c00 mm/mmap.c:2550 do_mmap+0x825/0xf50 mm/mmap.c:1412 vm_mmap_pgoff+0x1ab/0x270 mm/util.c:520 ksys_mmap_pgoff+0x41b/0x5a0 mm/mmap.c:1458 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 drain_vmap_area_work+0x52/0xe0 mm/vmalloc.c:1799 process_one_work+0x9bf/0x1710 kernel/workqueue.c:2289 worker_thread+0x665/0x1080 kernel/workqueue.c:2436 kthread+0x2e4/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306 Memory state around the buggy address: ffff88807846fd00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88807846fd80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88807846fe00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88807846fe80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88807846ff00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ================================================================== ---------------- Code disassembly (best guess): 0: 03 74 c0 01 add 0x1(%rax,%rax,8),%esi 4: 10 05 03 74 b8 01 adc %al,0x1b87403(%rip) # 0x1b8740d a: 10 06 adc %al,(%rsi) c: 03 74 b4 01 add 0x1(%rsp,%rsi,4),%esi 10: 10 07 adc %al,(%rdi) 12: 03 74 b0 01 add 0x1(%rax,%rsi,4),%esi 16: 10 08 adc %cl,(%rax) 18: 03 74 d8 01 add 0x1(%rax,%rbx,8),%esi 1c: 00 00 add %al,(%rax) 1e: 00 00 add %al,(%rax) 20: 00 51 52 add %dl,0x52(%rcx) 23: 55 push %rbp 24: 89 e5 mov %esp,%ebp 26: 0f 34 sysenter 28: cd 80 int $0x80 * 2a: 5d pop %rbp <-- trapping instruction 2b: 5a pop %rdx 2c: 59 pop %rcx 2d: c3 retq 2e: 90 nop 2f: 90 nop 30: 90 nop 31: 90 nop 32: 8d b4 26 00 00 00 00 lea 0x0(%rsi,%riz,1),%esi 39: 8d b4 26 00 00 00 00 lea 0x0(%rsi,%riz,1),%esi