================================================================== BUG: KASAN: use-after-free in mas_safe_min lib/maple_tree.c:715 [inline] BUG: KASAN: use-after-free in mas_next_nentry+0x9e4/0xab0 lib/maple_tree.c:4541 Read of size 8 at addr ffff88807b281420 by task syz-executor182/3619 CPU: 0 PID: 3619 Comm: syz-executor182 Not tainted 5.19.0-rc1-next-20220610-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description.constprop.0.cold+0xeb/0x495 mm/kasan/report.c:313 print_report mm/kasan/report.c:429 [inline] kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491 mas_safe_min lib/maple_tree.c:715 [inline] mas_next_nentry+0x9e4/0xab0 lib/maple_tree.c:4541 mas_next_entry lib/maple_tree.c:4636 [inline] mas_next+0x1fb/0xc90 lib/maple_tree.c:5726 userfaultfd_unregister fs/userfaultfd.c:1652 [inline] userfaultfd_ioctl+0x344c/0x41f0 fs/userfaultfd.c:2002 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+0x46/0xb0 RIP: 0033:0x7f13bfecee99 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 11 15 00 00 90 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:00007f13bfe5f208 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f13bff57418 RCX: 00007f13bfecee99 RDX: 00000000200000c0 RSI: 000000008010aa01 RDI: 0000000000000004 RBP: 00007f13bff57410 R08: 00007f13bfe5f700 R09: 00007f13bff57418 R10: 00007f13bfe5f700 R11: 0000000000000246 R12: 00007f13bff5741c R13: 00007fffe9d11aef R14: 00007f13bfe5f300 R15: 0000000000022000 Allocated by task 3616: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:45 [inline] set_alloc_info mm/kasan/common.c:436 [inline] __kasan_slab_alloc+0x90/0xc0 mm/kasan/common.c:469 kasan_slab_alloc include/linux/kasan.h:224 [inline] slab_post_alloc_hook mm/slab.h:750 [inline] kmem_cache_alloc_bulk+0x39f/0x720 mm/slub.c:3728 mt_alloc_bulk lib/maple_tree.c:151 [inline] mas_alloc_nodes+0x1df/0x6b0 lib/maple_tree.c:1244 mas_node_count+0x101/0x130 lib/maple_tree.c:1303 mas_split lib/maple_tree.c:3406 [inline] mas_commit_b_node lib/maple_tree.c:3507 [inline] mas_wr_modify+0x24a1/0x5a50 lib/maple_tree.c:4246 mas_wr_store_entry.isra.0+0x5c3/0xf90 lib/maple_tree.c:4284 mas_store+0xac/0xf0 lib/maple_tree.c:5525 dup_mmap+0x88a/0x1090 kernel/fork.c:687 dup_mm+0x91/0x370 kernel/fork.c:1520 copy_mm kernel/fork.c:1569 [inline] copy_process+0x3c95/0x7080 kernel/fork.c:2234 kernel_clone+0xe7/0xab0 kernel/fork.c:2649 __do_sys_clone+0xba/0x100 kernel/fork.c:2783 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+0x46/0xb0 Freed by task 3619: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track+0x21/0x30 mm/kasan/common.c:45 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370 ____kasan_slab_free mm/kasan/common.c:366 [inline] ____kasan_slab_free+0x166/0x1a0 mm/kasan/common.c:328 kasan_slab_free include/linux/kasan.h:200 [inline] slab_free_hook mm/slub.c:1727 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1753 slab_free mm/slub.c:3507 [inline] kmem_cache_free_bulk mm/slub.c:3654 [inline] kmem_cache_free_bulk+0x2c0/0xb60 mm/slub.c:3641 mt_free_bulk lib/maple_tree.c:157 [inline] mas_destroy+0x394/0x5c0 lib/maple_tree.c:5688 mas_store_prealloc+0xec/0x150 lib/maple_tree.c:5569 __vma_adjust+0x6d7/0x1900 mm/mmap.c:832 vma_adjust include/linux/mm.h:2659 [inline] __split_vma+0x443/0x530 mm/mmap.c:2299 split_vma+0x9f/0xe0 mm/mmap.c:2332 userfaultfd_unregister fs/userfaultfd.c:1631 [inline] userfaultfd_ioctl+0x3896/0x41f0 fs/userfaultfd.c:2002 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+0x46/0xb0 The buggy address belongs to the object at ffff88807b281400 which belongs to the cache maple_node of size 256 The buggy address is located 32 bytes inside of 256-byte region [ffff88807b281400, ffff88807b281500) The buggy address belongs to the physical page: page:ffffea0001eca000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7b280 head:ffffea0001eca000 order:1 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 0000000000000000 dead000000000122 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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3616, tgid 3616 (syz-executor182), ts 50584920245, free_ts 50521645564 prep_new_page mm/page_alloc.c:2460 [inline] get_page_from_freelist+0xa64/0x3d10 mm/page_alloc.c:4279 __alloc_pages+0x1c7/0x510 mm/page_alloc.c:5500 alloc_pages+0x1aa/0x310 mm/mempolicy.c:2279 alloc_slab_page mm/slub.c:1797 [inline] allocate_slab+0x26c/0x3c0 mm/slub.c:1942 new_slab mm/slub.c:2002 [inline] ___slab_alloc+0x985/0xd90 mm/slub.c:3002 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3089 slab_alloc_node mm/slub.c:3180 [inline] slab_alloc mm/slub.c:3222 [inline] __kmem_cache_alloc_lru mm/slub.c:3229 [inline] kmem_cache_alloc+0x360/0x3b0 mm/slub.c:3239 mt_alloc_one lib/maple_tree.c:146 [inline] mas_alloc_nodes+0x377/0x6b0 lib/maple_tree.c:1219 mas_preallocate+0xfb/0x270 lib/maple_tree.c:5584 mmap_region+0xcfc/0x1bf0 mm/mmap.c:2736 do_mmap+0x825/0xf60 mm/mmap.c:1480 vm_mmap_pgoff+0x1b7/0x290 mm/util.c:520 ksys_mmap_pgoff+0x79/0x5a0 mm/mmap.c:1526 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+0x46/0xb0 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1375 [inline] free_pcp_prepare+0x549/0xd20 mm/page_alloc.c:1425 free_unref_page_prepare mm/page_alloc.c:3311 [inline] free_unref_page+0x19/0x7b0 mm/page_alloc.c:3426 __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2521 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+0xa2/0xc0 mm/kasan/common.c:446 kasan_slab_alloc include/linux/kasan.h:224 [inline] slab_post_alloc_hook mm/slab.h:750 [inline] slab_alloc_node mm/slub.c:3214 [inline] slab_alloc mm/slub.c:3222 [inline] __kmalloc+0x200/0x350 mm/slub.c:4413 kmalloc include/linux/slab.h:605 [inline] tomoyo_add_entry security/tomoyo/common.c:2022 [inline] tomoyo_supervisor+0xb57/0xf00 security/tomoyo/common.c:2094 tomoyo_audit_env_log security/tomoyo/environ.c:36 [inline] tomoyo_env_perm+0x17f/0x1f0 security/tomoyo/environ.c:63 tomoyo_environ security/tomoyo/domain.c:672 [inline] tomoyo_find_next_domain+0x13ce/0x1f80 security/tomoyo/domain.c:879 tomoyo_bprm_check_security security/tomoyo/tomoyo.c:101 [inline] tomoyo_bprm_check_security+0x121/0x1a0 security/tomoyo/tomoyo.c:91 security_bprm_check+0x45/0xa0 security/security.c:867 search_binary_handler fs/exec.c:1716 [inline] exec_binprm fs/exec.c:1769 [inline] bprm_execve fs/exec.c:1838 [inline] bprm_execve+0x732/0x1970 fs/exec.c:1800 do_execveat_common+0x724/0x890 fs/exec.c:1943 do_execve fs/exec.c:2017 [inline] __do_sys_execve fs/exec.c:2093 [inline] __se_sys_execve fs/exec.c:2088 [inline] __x64_sys_execve+0x8f/0xc0 fs/exec.c:2088 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 Memory state around the buggy address: ffff88807b281300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88807b281380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88807b281400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88807b281480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88807b281500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================