================================================================== 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 ffff88807ca07e20 by task syz-executor.0/19001 CPU: 0 PID: 19001 Comm: syz-executor.0 Not tainted 6.0.0-rc6-next-20220923-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/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 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:0x7fc920c8a5a9 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:00007fc921ed9168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007fc920dabf80 RCX: 00007fc920c8a5a9 RDX: 0000000020000040 RSI: 000000008010aa01 RDI: 0000000000000003 RBP: 00007fc920ce5580 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffc9d5ec9af R14: 00007fc921ed9300 R15: 0000000000022000 Allocated by task 3644: 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:754 [inline] kmem_cache_alloc_bulk+0x3f8/0x860 mm/slub.c:3792 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+0x3bc6/0x71b0 kernel/fork.c:2256 kernel_clone+0xe7/0x980 kernel/fork.c:2676 __do_sys_clone+0xba/0x100 kernel/fork.c:2817 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 19001: 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:1669 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1695 slab_free mm/slub.c:3599 [inline] kmem_cache_free_bulk.part.0+0x205/0x780 mm/slub.c:3717 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:2664 [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 ffff88807ca07e00 which belongs to the cache maple_node of size 256 The buggy address is located 32 bytes inside of 256-byte region [ffff88807ca07e00, ffff88807ca07f00) The buggy address belongs to the physical page: page:ffffea0001f28180 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffffea0001e22a00 pfn:0x7ca06 head:ffffea0001f28180 order:1 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 ffff88801184fdc0 dead000000100010 0000000000000000 raw: ffffea0001e22a00 dead000000000004 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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3596, tgid 3596 (sshd), ts 38200348689, free_ts 38193435377 prep_new_page mm/page_alloc.c:2538 [inline] get_page_from_freelist+0x1092/0x2d20 mm/page_alloc.c:4287 __alloc_pages+0x1c7/0x5a0 mm/page_alloc.c:5546 alloc_pages+0x1a6/0x270 mm/mempolicy.c:2280 alloc_slab_page mm/slub.c:1739 [inline] allocate_slab+0x213/0x300 mm/slub.c:1884 new_slab mm/slub.c:1937 [inline] ___slab_alloc+0xac1/0x1430 mm/slub.c:3119 kmem_cache_alloc_bulk+0x291/0x860 mm/slub.c:3768 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:2664 [inline] __split_vma+0x295/0x5c0 mm/mmap.c:2239 split_vma+0x9f/0xe0 mm/mmap.c:2272 mprotect_fixup+0x746/0x960 mm/mprotect.c:621 do_mprotect_pkey+0x6fd/0xa70 mm/mprotect.c:790 __do_sys_mprotect mm/mprotect.c:817 [inline] __se_sys_mprotect mm/mprotect.c:814 [inline] __x64_sys_mprotect+0x74/0xb0 mm/mprotect.c:814 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:2532 qlink_free mm/kasan/quarantine.c:168 [inline] qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x180/0x200 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:3336 [inline] slab_alloc mm/slub.c:3344 [inline] __kmem_cache_alloc_lru mm/slub.c:3351 [inline] kmem_cache_alloc+0x2b7/0x3d0 mm/slub.c:3360 vm_area_alloc+0x1c/0xf0 kernel/fork.c:458 mmap_region+0x448/0x1bf0 mm/mmap.c:2604 do_mmap+0x825/0xf50 mm/mmap.c:1411 vm_mmap_pgoff+0x1ab/0x270 mm/util.c:520 ksys_mmap_pgoff+0x41b/0x5a0 mm/mmap.c:1457 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: ffff88807ca07d00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88807ca07d80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88807ca07e00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88807ca07e80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88807ca07f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================