================================================================== BUG: KASAN: use-after-free in mas_leaf_max_gap+0x608/0x6a0 lib/maple_tree.c:1500 Read of size 8 at addr ffff88807447f880 by task syz-executor.3/32003 CPU: 0 PID: 32003 Comm: syz-executor.3 Not tainted 6.1.0-rc3-syzkaller-00239-g10d916c86eca #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/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_leaf_max_gap+0x608/0x6a0 lib/maple_tree.c:1500 mas_max_gap lib/maple_tree.c:1569 [inline] mab_set_b_end lib/maple_tree.c:2648 [inline] mas_spanning_rebalance.isra.0+0x429d/0x58a0 lib/maple_tree.c:3038 mas_wr_spanning_store.isra.0+0x5c8/0xfc0 lib/maple_tree.c:4046 mas_wr_store_entry.isra.0+0xb13/0xf90 lib/maple_tree.c:4388 mas_store_prealloc+0xaf/0x150 lib/maple_tree.c:5702 do_mas_align_munmap+0x761/0xee0 mm/mmap.c:2428 do_mas_munmap+0x26a/0x2b0 mm/mmap.c:2502 do_munmap+0xc3/0x100 mm/mmap.c:2516 mremap_to mm/mremap.c:826 [inline] __do_sys_mremap+0x12ce/0x16b0 mm/mremap.c:972 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:0x7f3910e8b5a9 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:00007f3911c6b168 EFLAGS: 00000246 ORIG_RAX: 0000000000000019 RAX: ffffffffffffffda RBX: 00007f3910fabf80 RCX: 00007f3910e8b5a9 RDX: 0000000000004000 RSI: 00007fffdf5ca000 RDI: 0000000020a35000 RBP: 00007f3910ee67b0 R08: 0000000020a14000 R09: 0000000000000000 R10: 0000000000000003 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f39110cfb1f R14: 00007f3911c6b300 R15: 0000000000022000 Allocated by task 32003: 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] slab_alloc_node mm/slub.c:3398 [inline] slab_alloc mm/slub.c:3406 [inline] __kmem_cache_alloc_lru mm/slub.c:3413 [inline] kmem_cache_alloc+0x2ac/0x3c0 mm/slub.c:3422 mt_alloc_one lib/maple_tree.c:152 [inline] mas_alloc_nodes+0x429/0x810 lib/maple_tree.c:1231 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 do_munmap+0xc3/0x100 mm/mmap.c:2516 mremap_to mm/mremap.c:826 [inline] __do_sys_mremap+0x12ce/0x16b0 mm/mremap.c:972 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 32003: 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+0xea/0x5b0 mm/slub.c:3683 mas_destroy+0x2e1/0x5c0 lib/maple_tree.c:5771 mas_store_prealloc+0xec/0x150 lib/maple_tree.c:5704 __vma_adjust+0x772/0x1ae0 mm/mmap.c:811 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 do_munmap+0xc3/0x100 mm/mmap.c:2516 mremap_to mm/mremap.c:826 [inline] __do_sys_mremap+0x12ce/0x16b0 mm/mremap.c:972 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 ffff88807447f800 which belongs to the cache maple_node of size 256 The buggy address is located 128 bytes inside of 256-byte region [ffff88807447f800, ffff88807447f900) The buggy address belongs to the physical page: page:ffffea0001d11f80 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7447e head:ffffea0001d11f80 order:1 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 0000000000000000 dead000000000001 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 0x152800(GFP_NOWAIT|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_HARDWALL), pid 9440, tgid 9439 (syz-executor.1), ts 337437029438, free_ts 333285693068 prep_new_page mm/page_alloc.c:2539 [inline] get_page_from_freelist+0x10b5/0x2d50 mm/page_alloc.c:4288 __alloc_pages+0x1c7/0x5a0 mm/page_alloc.c:5555 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+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:613 dup_mm+0x91/0x370 kernel/fork.c:1526 copy_mm kernel/fork.c:1575 [inline] copy_process+0x3bc6/0x7190 kernel/fork.c:2253 kernel_clone+0xe7/0x980 kernel/fork.c:2671 __do_sys_clone+0xba/0x100 kernel/fork.c:2812 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:1459 [inline] free_pcp_prepare+0x65c/0xd90 mm/page_alloc.c:1509 free_unref_page_prepare mm/page_alloc.c:3387 [inline] free_unref_page+0x19/0x4d0 mm/page_alloc.c:3483 __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2586 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:737 [inline] slab_alloc_node mm/slub.c:3398 [inline] kmem_cache_alloc_node+0x1be/0x400 mm/slub.c:3443 __alloc_skb+0x210/0x2f0 net/core/skbuff.c:497 alloc_skb include/linux/skbuff.h:1267 [inline] alloc_skb_with_frags+0x93/0x6c0 net/core/skbuff.c:6124 sock_alloc_send_pskb+0x7a3/0x930 net/core/sock.c:2719 unix_dgram_sendmsg+0x415/0x1b50 net/unix/af_unix.c:1943 sock_sendmsg_nosec net/socket.c:714 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:734 __sys_sendto+0x236/0x340 net/socket.c:2117 __do_sys_sendto net/socket.c:2129 [inline] __se_sys_sendto net/socket.c:2125 [inline] __x64_sys_sendto+0xdd/0x1b0 net/socket.c:2125 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: ffff88807447f780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88807447f800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88807447f880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88807447f900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88807447f980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================