================================================================== BUG: KASAN: slab-use-after-free in madvise_collapse+0xa6c/0xb50 mm/khugepaged.c:2723 Read of size 8 at addr ffff8880225c3588 by task syz-executor.1/19300 CPU: 1 PID: 19300 Comm: syz-executor.1 Not tainted 6.5.0-rc2-next-20230718-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/03/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:364 [inline] print_report+0xc4/0x620 mm/kasan/report.c:475 kasan_report+0xda/0x110 mm/kasan/report.c:588 madvise_collapse+0xa6c/0xb50 mm/khugepaged.c:2723 madvise_vma_behavior+0x200/0x1e60 mm/madvise.c:1094 madvise_walk_vmas+0x1cf/0x2c0 mm/madvise.c:1268 do_madvise+0x333/0x660 mm/madvise.c:1448 __do_sys_madvise mm/madvise.c:1461 [inline] __se_sys_madvise mm/madvise.c:1459 [inline] __x64_sys_madvise+0xaa/0x110 mm/madvise.c:1459 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fe9efc7cb29 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 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 b0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fe9f0a9c0c8 EFLAGS: 00000246 ORIG_RAX: 000000000000001c RAX: ffffffffffffffda RBX: 00007fe9efd9c050 RCX: 00007fe9efc7cb29 RDX: 0000000000000019 RSI: 000000000060005f RDI: 0000000020000000 RBP: 00007fe9efcc847a R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 000000000000006e R14: 00007fe9efd9c050 R15: 00007ffc36fcfc58 Allocated by task 19268: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 __kasan_slab_alloc+0x81/0x90 mm/kasan/common.c:328 kasan_slab_alloc include/linux/kasan.h:186 [inline] slab_post_alloc_hook mm/slab.h:762 [inline] slab_alloc_node mm/slub.c:3478 [inline] slab_alloc mm/slub.c:3486 [inline] __kmem_cache_alloc_lru mm/slub.c:3493 [inline] kmem_cache_alloc+0x172/0x3b0 mm/slub.c:3502 vm_area_alloc+0x1f/0x220 kernel/fork.c:485 mmap_region+0x386/0x2640 mm/mmap.c:2726 do_mmap+0x884/0xee0 mm/mmap.c:1359 vm_mmap_pgoff+0x1a6/0x3b0 mm/util.c:543 ksys_mmap_pgoff+0x7d/0x5b0 mm/mmap.c:1405 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 19300: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:522 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x15e/0x1b0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:162 [inline] slab_free_hook mm/slub.c:1800 [inline] slab_free_freelist_hook+0x114/0x1e0 mm/slub.c:1826 slab_free mm/slub.c:3809 [inline] kmem_cache_free+0xf0/0x490 mm/slub.c:3831 rcu_do_batch kernel/rcu/tree.c:2139 [inline] rcu_core+0x7fb/0x1bb0 kernel/rcu/tree.c:2403 __do_softirq+0x218/0x965 kernel/softirq.c:553 Last potentially related work creation: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:492 __call_rcu_common.constprop.0+0x9a/0x790 kernel/rcu/tree.c:2653 remove_vma+0x140/0x170 mm/mmap.c:148 remove_mt mm/mmap.c:2289 [inline] do_vmi_align_munmap+0xfab/0x1720 mm/mmap.c:2556 do_vmi_munmap+0x20e/0x450 mm/mmap.c:2620 mmap_region+0x194/0x2640 mm/mmap.c:2670 do_mmap+0x884/0xee0 mm/mmap.c:1359 do_shmat+0xfb4/0x1320 ipc/shm.c:1665 __do_sys_shmat ipc/shm.c:1701 [inline] __se_sys_shmat ipc/shm.c:1696 [inline] __x64_sys_shmat+0xd8/0x170 ipc/shm.c:1696 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Second to last potentially related work creation: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:492 __call_rcu_common.constprop.0+0x9a/0x790 kernel/rcu/tree.c:2653 remove_vma+0x140/0x170 mm/mmap.c:148 remove_mt mm/mmap.c:2289 [inline] do_vmi_align_munmap+0xfab/0x1720 mm/mmap.c:2556 do_vmi_munmap+0x20e/0x450 mm/mmap.c:2620 mmap_region+0x194/0x2640 mm/mmap.c:2670 do_mmap+0x884/0xee0 mm/mmap.c:1359 vm_mmap_pgoff+0x1a6/0x3b0 mm/util.c:543 ksys_mmap_pgoff+0x422/0x5b0 mm/mmap.c:1405 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff8880225c3500 which belongs to the cache vm_area_struct of size 192 The buggy address is located 136 bytes inside of freed 192-byte region [ffff8880225c3500, ffff8880225c35c0) The buggy address belongs to the physical page: page:ffffea00008970c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x225c3 memcg:ffff88807a699e01 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000200 ffff888014674b40 ffffea0000ab1980 dead000000000004 raw: 0000000000000000 0000000000100010 00000001ffffffff ffff88807a699e01 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 11489, tgid 11487 (syz-executor.1), ts 378241365149, free_ts 377827571163 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x2d2/0x350 mm/page_alloc.c:1569 prep_new_page mm/page_alloc.c:1576 [inline] get_page_from_freelist+0x10d7/0x31b0 mm/page_alloc.c:3256 __alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4512 alloc_pages+0x1a9/0x270 mm/mempolicy.c:2279 alloc_slab_page mm/slub.c:1870 [inline] allocate_slab+0x24e/0x380 mm/slub.c:2017 new_slab mm/slub.c:2070 [inline] ___slab_alloc+0x8bc/0x1570 mm/slub.c:3223 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3322 __slab_alloc_node mm/slub.c:3375 [inline] slab_alloc_node mm/slub.c:3468 [inline] slab_alloc mm/slub.c:3486 [inline] __kmem_cache_alloc_lru mm/slub.c:3493 [inline] kmem_cache_alloc+0x392/0x3b0 mm/slub.c:3502 vm_area_alloc+0x1f/0x220 kernel/fork.c:485 mmap_region+0x386/0x2640 mm/mmap.c:2726 do_mmap+0x884/0xee0 mm/mmap.c:1359 vm_mmap_pgoff+0x1a6/0x3b0 mm/util.c:543 ksys_mmap_pgoff+0x7d/0x5b0 mm/mmap.c:1405 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/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:1160 [inline] free_unref_page_prepare+0x508/0xb90 mm/page_alloc.c:2383 free_unref_page_list+0xe6/0xb30 mm/page_alloc.c:2524 release_pages+0x32a/0x14e0 mm/swap.c:1042 tlb_batch_pages_flush+0x9a/0x190 mm/mmu_gather.c:97 tlb_flush_mmu_free mm/mmu_gather.c:292 [inline] tlb_flush_mmu mm/mmu_gather.c:299 [inline] tlb_finish_mmu+0x14b/0x7e0 mm/mmu_gather.c:391 exit_mmap+0x2db/0x960 mm/mmap.c:3209 __mmput+0x12a/0x4d0 kernel/fork.c:1356 mmput+0x62/0x70 kernel/fork.c:1378 exit_mm kernel/exit.c:567 [inline] do_exit+0x9b4/0x2a20 kernel/exit.c:861 do_group_exit+0xd4/0x2a0 kernel/exit.c:1024 __do_sys_exit_group kernel/exit.c:1035 [inline] __se_sys_exit_group kernel/exit.c:1033 [inline] __x64_sys_exit_group+0x3e/0x50 kernel/exit.c:1033 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Memory state around the buggy address: ffff8880225c3480: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff8880225c3500: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8880225c3580: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ^ ffff8880225c3600: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880225c3680: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ==================================================================