syzbot


KASAN: slab-use-after-free Read in __vma_reservation_common

Status: upstream: reported syz repro on 2024/04/12 13:32
Subsystems: mm
[Documentation on labels]
Reported-by: syzbot+ad1b592fc4483655438b@syzkaller.appspotmail.com
Fix commit: 37641efaa3fa hugetlb: check for anon_vma prior to folio allocation
Patched on: [ci-qemu-upstream ci-qemu-upstream-386 ci-qemu2-arm32 ci-qemu2-arm64 ci-qemu2-arm64-compat ci-qemu2-arm64-mte ci-upstream-bpf-kasan-gce ci-upstream-bpf-next-kasan-gce ci-upstream-gce-arm64 ci-upstream-gce-leak ci-upstream-kasan-badwrites-root ci-upstream-kasan-gce ci-upstream-kasan-gce-386 ci-upstream-kasan-gce-root ci-upstream-kasan-gce-selinux-root ci-upstream-kasan-gce-smack-root ci-upstream-kmsan-gce-386-root ci-upstream-kmsan-gce-root ci-upstream-linux-next-kasan-gce-root ci-upstream-net-kasan-gce ci-upstream-net-this-kasan-gce ci2-upstream-fs ci2-upstream-kcsan-gce ci2-upstream-net-next-test-gce ci2-upstream-usb], missing on: [ci-qemu2-riscv64]
First crash: 39d, last: 21d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [mm?] KASAN: slab-use-after-free Read in __vma_reservation_common 11 (18) 2024/04/19 05:01
Last patch testing requests (4)
Created Duration User Patch Repo Result
2024/04/18 18:45 2h17m vishal.moola@gmail.com patch https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git linus error OK
2024/04/15 22:05 2h25m vishal.moola@gmail.com patch https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 9ed46da14b9b OK log
2024/04/14 03:31 24m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 9ed46da14b9b OK log
2024/04/13 23:33 57m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 9ed46da14b9b report log

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in is_vm_hugetlb_page include/linux/hugetlb_inline.h:11 [inline]
BUG: KASAN: slab-use-after-free in vma_resv_map mm/hugetlb.c:1150 [inline]
BUG: KASAN: slab-use-after-free in __vma_reservation_common+0xc9/0x7d0 mm/hugetlb.c:2806
Read of size 8 at addr ffff88805f2e99d0 by task syz-executor.4/15694

CPU: 0 PID: 15694 Comm: syz-executor.4 Not tainted 6.9.0-rc4-next-20240418-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report+0x143/0x180 mm/kasan/report.c:601
 is_vm_hugetlb_page include/linux/hugetlb_inline.h:11 [inline]
 vma_resv_map mm/hugetlb.c:1150 [inline]
 __vma_reservation_common+0xc9/0x7d0 mm/hugetlb.c:2806
 vma_needs_reservation mm/hugetlb.c:2880 [inline]
 restore_reserve_on_error+0x39/0x1d0 mm/hugetlb.c:2930
 hugetlb_no_page mm/hugetlb.c:6393 [inline]
 hugetlb_fault+0x23b4/0x3890 mm/hugetlb.c:6489
 handle_mm_fault+0x18e8/0x1bb0 mm/memory.c:5663
 do_user_addr_fault arch/x86/mm/fault.c:1369 [inline]
 handle_page_fault arch/x86/mm/fault.c:1512 [inline]
 exc_page_fault+0x459/0x900 arch/x86/mm/fault.c:1570
 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623
RIP: 0033:0x7f6639e37b31
Code: 01 64 48 8b 04 25 00 00 00 00 48 8d b8 e0 fe ff ff e8 23 96 00 00 85 c0 75 17 48 8b 84 24 18 01 00 00 48 8b b4 24 30 01 00 00 <48> 89 b0 00 00 00 20 64 f0 83 2c 25 a8 ff ff ff 01 eb 56 48 8d ac
RSP: 002b:00007ffef196b9f0 EFLAGS: 00010246
RAX: 0000000000000240 RBX: 0000000000000001 RCX: fffffffffffffeff
RDX: cb77cc19e04d9a7b RSI: 0000000020000100 RDI: 0000555573f5e360
RBP: 00007f6639fac050 R08: 00007f6639e00000 R09: 0000000000000004
R10: 0000000000000000 R11: 0000000000000001 R12: 00007ffef196bba0
R13: 0000000000000001 R14: ffffffffffffffff R15: 00007f6639e34cb0
 </TASK>

Allocated by task 15696:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 unpoison_slab_object mm/kasan/common.c:312 [inline]
 __kasan_slab_alloc+0x66/0x80 mm/kasan/common.c:338
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slub.c:3897 [inline]
 slab_alloc_node mm/slub.c:3957 [inline]
 kmem_cache_alloc_noprof+0x135/0x290 mm/slub.c:3964
 vm_area_alloc+0x24/0x1d0 kernel/fork.c:467
 mmap_region+0xc47/0x2060 mm/mmap.c:2873
 do_mmap+0x8ad/0xfa0 mm/mmap.c:1397
 vm_mmap_pgoff+0x1dd/0x3d0 mm/util.c:573
 ksys_mmap_pgoff+0x544/0x720 mm/mmap.c:1443
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 24:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579
 poison_slab_object+0xe0/0x150 mm/kasan/common.c:240
 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2190 [inline]
 slab_free mm/slub.c:4393 [inline]
 kmem_cache_free+0x145/0x340 mm/slub.c:4468
 rcu_do_batch kernel/rcu/tree.c:2565 [inline]
 rcu_core+0xafd/0x1830 kernel/rcu/tree.c:2839
 __do_softirq+0x2c6/0x980 kernel/softirq.c:554

Last potentially related work creation:
 kasan_save_stack+0x3f/0x60 mm/kasan/common.c:47
 __kasan_record_aux_stack+0xac/0xc0 mm/kasan/generic.c:541
 __call_rcu_common kernel/rcu/tree.c:3102 [inline]
 call_rcu+0x167/0xa70 kernel/rcu/tree.c:3206
 remove_vma mm/mmap.c:148 [inline]
 remove_mt mm/mmap.c:2344 [inline]
 do_vmi_align_munmap+0x155c/0x18c0 mm/mmap.c:2687
 do_vmi_munmap+0x265/0x2f0 mm/mmap.c:2759
 mmap_region+0x729/0x2060 mm/mmap.c:2810
 do_mmap+0x8ad/0xfa0 mm/mmap.c:1397
 vm_mmap_pgoff+0x1dd/0x3d0 mm/util.c:573
 ksys_mmap_pgoff+0x544/0x720 mm/mmap.c:1443
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff88805f2e99b0
 which belongs to the cache vm_area_struct of size 184
The buggy address is located 32 bytes inside of
 freed 184-byte region [ffff88805f2e99b0, ffff88805f2e9a68)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5f2e9
memcg:ffff88802991d101
flags: 0xfff80000000000(node=0|zone=1|lastcpupid=0xfff)
page_type: 0xffffefff(slab)
raw: 00fff80000000000 ffff888015eebb40 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000100010 00000001ffffefff ffff88802991d101
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x152cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 15679, tgid 495500522 (syz-executor.3), ts 15682, free_ts 361259445994
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1476
 prep_new_page mm/page_alloc.c:1484 [inline]
 get_page_from_freelist+0x2ce2/0x2d90 mm/page_alloc.c:3446
 __alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4704
 __alloc_pages_node_noprof include/linux/gfp.h:244 [inline]
 alloc_pages_node_noprof include/linux/gfp.h:271 [inline]
 alloc_slab_page+0x5f/0x120 mm/slub.c:2259
 allocate_slab+0x5a/0x2e0 mm/slub.c:2422
 new_slab mm/slub.c:2475 [inline]
 ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3624
 __slab_alloc+0x58/0xa0 mm/slub.c:3714
 __slab_alloc_node mm/slub.c:3767 [inline]
 slab_alloc_node mm/slub.c:3945 [inline]
 kmem_cache_alloc_noprof+0x1c1/0x290 mm/slub.c:3964
 vm_area_alloc+0x24/0x1d0 kernel/fork.c:467
 mmap_region+0xc47/0x2060 mm/mmap.c:2873
 do_mmap+0x8ad/0xfa0 mm/mmap.c:1397
 vm_mmap_pgoff+0x1dd/0x3d0 mm/util.c:573
 ksys_mmap_pgoff+0x544/0x720 mm/mmap.c:1443
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
page last free pid 15681 tgid 15681 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1096 [inline]
 free_unref_folios+0xf23/0x19e0 mm/page_alloc.c:2658
 folios_put_refs+0x93a/0xa60 mm/swap.c:1022
 free_pages_and_swap_cache+0x5c8/0x690 mm/swap_state.c:332
 __tlb_batch_free_encoded_pages mm/mmu_gather.c:136 [inline]
 tlb_batch_pages_flush mm/mmu_gather.c:149 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:366 [inline]
 tlb_flush_mmu+0x3a3/0x680 mm/mmu_gather.c:373
 tlb_finish_mmu+0xd4/0x200 mm/mmu_gather.c:465
 exit_mmap+0x44f/0xc80 mm/mmap.c:3354
 __mmput+0x115/0x3c0 kernel/fork.c:1346
 exit_mm+0x220/0x310 kernel/exit.c:568
 do_exit+0x99e/0x27e0 kernel/exit.c:864
 do_group_exit+0x207/0x2c0 kernel/exit.c:1026
 __do_sys_exit_group kernel/exit.c:1037 [inline]
 __se_sys_exit_group kernel/exit.c:1035 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1035
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
 ffff88805f2e9880: fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00 00
 ffff88805f2e9900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc
>ffff88805f2e9980: fc fc fc fc fc fc fa fb fb fb fb fb fb fb fb fb
                                                 ^
 ffff88805f2e9a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc
 ffff88805f2e9a80: fc fc fc fc fc fa fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (13):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/04/19 22:00 linux-next 7b4f2bc91c15 af24b050 .config console log report syz [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in __vma_reservation_common
2024/04/13 18:33 linux-next 9ed46da14b9b c8349e48 .config console log report syz [disk image] [vmlinux] [kernel image] [mounted in repro] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in __vma_reservation_common
2024/04/25 14:55 upstream e88c4cfcb7b8 8bdc0f22 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in __vma_reservation_common
2024/04/23 18:44 upstream 71b1543c83d6 21339d7b .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in __vma_reservation_common
2024/04/22 10:38 upstream ed30a4a51bb1 36c961ad .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in __vma_reservation_common
2024/04/21 12:53 upstream 977b1ef51866 af24b050 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in __vma_reservation_common
2024/04/26 11:43 upstream c942a0cd3603 059e9963 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-386 KASAN: slab-use-after-free Read in __vma_reservation_common
2024/04/23 14:07 linux-next 7b4f2bc91c15 21339d7b .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in __vma_reservation_common
2024/04/19 20:48 linux-next 7b4f2bc91c15 af24b050 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in __vma_reservation_common
2024/04/13 21:51 linux-next 9ed46da14b9b c8349e48 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in __vma_reservation_common
2024/04/13 17:46 linux-next 9ed46da14b9b c8349e48 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in __vma_reservation_common
2024/04/08 22:38 linux-next 11cb68ad52ac 53df08b6 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in __vma_reservation_common
2024/04/08 13:19 linux-next 11cb68ad52ac ca620dd8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in __vma_reservation_common
* Struck through repros no longer work on HEAD.