================================================================== 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 ffff88807bd74a20 by task syz-executor.1/9133 CPU: 0 PID: 9133 Comm: syz-executor.1 Not tainted 6.1.0-rc1-next-20221021-syzkaller #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:253 [inline] print_report+0x15e/0x45d mm/kasan/report.c:364 kasan_report+0xbb/0x1f0 mm/kasan/report.c:464 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:0x7ff9e548b5a9 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:00007ff9e614e168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007ff9e55abf80 RCX: 00007ff9e548b5a9 RDX: 0000000020000040 RSI: 000000008010aa01 RDI: 0000000000000003 RBP: 00007ff9e54e67b0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fff5ba43f8f R14: 00007ff9e614e300 R15: 0000000000022000 Allocated by task 3636: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:45 __kasan_unpoison_range-0xf/0x10 __kasan_kmalloc_large-0x2/0xe0 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook mm/slab.h:754 [inline] kmem_cache_alloc_bulk+0x3e9/0x830 mm/slub.c:3859 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:616 dup_mm+0x91/0x370 kernel/fork.c:1529 copy_mm kernel/fork.c:1578 [inline] copy_process+0x43a9/0x7230 kernel/fork.c:2247 kernel_clone+0xe7/0x980 kernel/fork.c:2667 __do_sys_clone+0xba/0x100 kernel/fork.c:2808 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 9133: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:45 __kasan_unpoison_range-0xf/0x10 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:3666 [inline] kmem_cache_free_bulk.part.0+0x205/0x780 mm/slub.c:3784 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:2633 [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 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 ffff88807bd74a00 which belongs to the cache maple_node of size 256 The buggy address is located 32 bytes inside of 256-byte region [ffff88807bd74a00, ffff88807bd74b00) The buggy address belongs to the physical page: page:ffffea0001ef5d00 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffffea0001fc3200 pfn:0x7bd74 head:ffffea0001ef5d00 order:1 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 ffff88801184fdc0 dead000000100010 0000000000000000 raw: ffffea0001fc3200 dead000000000003 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 6583, tgid 6583 (modprobe), ts 337317697747, free_ts 337175154505 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:5546 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:3185 kmem_cache_alloc_bulk+0x28b/0x830 mm/slub.c:3835 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 mmap_region+0x76c/0x1c00 mm/mmap.c:2681 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 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 __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2591 qlink_free mm/kasan/quarantine.c:168 [inline] qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x18e/0x220 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0x62/0x80 mm/kasan/common.c:302 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook mm/slab.h:754 [inline] slab_alloc_node mm/slub.c:3403 [inline] slab_alloc mm/slub.c:3411 [inline] __kmem_cache_alloc_lru mm/slub.c:3418 [inline] kmem_cache_alloc+0x2ac/0x3c0 mm/slub.c:3427 getname_flags.part.0+0x50/0x4f0 fs/namei.c:139 getname_flags include/linux/audit.h:320 [inline] getname+0x8e/0xd0 fs/namei.c:218 do_sys_openat2+0xf5/0x4c0 fs/open.c:1304 do_sys_open fs/open.c:1326 [inline] __do_sys_openat fs/open.c:1342 [inline] __se_sys_openat fs/open.c:1337 [inline] __x64_sys_openat+0x13f/0x1f0 fs/open.c:1337 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 Memory state around the buggy address: ffff88807bd74900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88807bd74980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88807bd74a00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88807bd74a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88807bd74b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================