================================================================== 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 ffff888078cde820 by task syz-executor.2/9487 CPU: 0 PID: 9487 Comm: syz-executor.2 Not tainted 6.0.0-rc6-next-20220923-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/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:0x7f017548a669 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:00007f0176557168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f01755abf80 RCX: 00007f017548a669 RDX: 0000000020000080 RSI: 000000008010aa01 RDI: 0000000000000004 RBP: 00007f01754e5560 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffc01bedcdf R14: 00007f0176557300 R15: 0000000000022000 Allocated by task 9487: 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 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+0x4b0/0x5c0 mm/mmap.c:2236 do_mas_align_munmap+0x54c/0xee0 mm/mmap.c:2361 do_mas_munmap+0x26a/0x2b0 mm/mmap.c:2501 mmap_region+0x219/0x1bf0 mm/mmap.c:2549 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 Freed by task 9487: 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+0x765/0x1a70 mm/mmap.c:810 vma_adjust include/linux/mm.h:2664 [inline] __split_vma+0x295/0x5c0 mm/mmap.c:2239 split_vma+0x9f/0xe0 mm/mmap.c:2272 userfaultfd_unregister fs/userfaultfd.c:1641 [inline] userfaultfd_ioctl+0x3819/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 ffff888078cde800 which belongs to the cache maple_node of size 256 The buggy address is located 32 bytes inside of 256-byte region [ffff888078cde800, ffff888078cde900) The buggy address belongs to the physical page: page:ffffea0001e33780 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffffea00009dda80 pfn:0x78cde head:ffffea0001e33780 order:1 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 ffff88801184fdc0 dead000000100010 0000000000000000 raw: ffffea00009dda80 0000000000000003 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 9172, tgid 9172 (syz-executor.5), ts 370225230913, free_ts 348328039252 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_expand+0x1cc/0xb60 mm/mmap.c:542 mmap_region+0x1376/0x1bf0 mm/mmap.c:2591 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 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:2642 [inline] apply_to_pmd_range mm/memory.c:2686 [inline] apply_to_pud_range mm/memory.c:2722 [inline] apply_to_p4d_range mm/memory.c:2758 [inline] __apply_to_page_range+0x68c/0x1030 mm/memory.c:2792 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: ffff888078cde700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888078cde780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff888078cde800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888078cde880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888078cde900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================