syzbot


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

Status: auto-obsoleted due to no activity on 2024/08/19 13:32
Subsystems: mm
[Documentation on labels]
Reported-by: syzbot+7fd4b85697bcf2a9daa2@syzkaller.appspotmail.com
First crash: 252d, last: 224d
Cause bisection: introduced by (bisect log) :
commit 7c43a553792a1701affeef20959dfb2ccb26dcee
Author: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Date: Wed Feb 21 23:47:32 2024 +0000

  hugetlb: allow faults to be handled under the VMA lock

Crash: KASAN: slab-use-after-free Read in hugetlb_fault (log)
Repro: C syz .config
  
Fix bisection: fixed by (bisect log) :
commit ed74abcd1da0244c3c3be865587dc2727148ee83
Author: Muhammad Usama Anjum <usama.anjum@collabora.com>
Date: Fri Apr 19 11:50:27 2024 +0000

  selftests: mm: protection_keys: save/restore nr_hugepages value from launch script

  
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [mm?] KASAN: slab-use-after-free Read in hugetlb_fault 2 (6) 2024/06/10 21:02
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-use-after-free Read in hugetlb_fault (2) mm 2 100d 104d 28/28 fixed on 2024/10/22 11:57
upstream KASAN: use-after-free Read in hugetlb_fault mm C 383 695d 790d 22/28 fixed on 2023/02/24 13:50
Last patch testing requests (6)
Created Duration User Patch Repo Result
2024/05/25 19:50 21m retest repro upstream OK log
2024/05/25 19:50 21m retest repro upstream OK log
2024/05/25 15:34 46m retest repro linux-next OK log
2024/05/25 13:40 21m retest repro upstream OK log
2024/04/18 10:49 1h40m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 9ed46da14b9b OK log
2024/04/17 23:13 1h30m 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 __vma_shareable_lock include/linux/hugetlb.h:1268 [inline]
BUG: KASAN: slab-use-after-free in hugetlb_vma_unlock_read mm/hugetlb.c:281 [inline]
BUG: KASAN: slab-use-after-free in hugetlb_no_page mm/hugetlb.c:6403 [inline]
BUG: KASAN: slab-use-after-free in hugetlb_fault+0x21ae/0x2f60 mm/hugetlb.c:6509
Read of size 8 at addr ffff88801ed56020 by task syz-executor121/6135

CPU: 0 PID: 6135 Comm: syz-executor121 Not tainted 6.9.0-rc4-syzkaller-00266-g977b1ef51866 #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
 __vma_shareable_lock include/linux/hugetlb.h:1268 [inline]
 hugetlb_vma_unlock_read mm/hugetlb.c:281 [inline]
 hugetlb_no_page mm/hugetlb.c:6403 [inline]
 hugetlb_fault+0x21ae/0x2f60 mm/hugetlb.c:6509
 handle_mm_fault+0x623/0x770 mm/memory.c:5604
 do_user_addr_fault arch/x86/mm/fault.c:1362 [inline]
 handle_page_fault arch/x86/mm/fault.c:1505 [inline]
 exc_page_fault+0x446/0x8e0 arch/x86/mm/fault.c:1563
 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623
RIP: 0033:0x7f1af2873291
Code: 39 c6 7e 57 4c 8b 5f 20 48 8b 57 28 eb 06 0f 1f 00 4c 89 c2 49 39 d3 74 47 4c 8b 57 18 4c 8d 42 01 89 c1 83 c0 08 4c 89 47 28 <41> 0f b6 14 12 89 47 34 48 d3 e2 49 09 d1 39 f0 7c d5 44 89 ca 29
RSP: 002b:00007f1af2840768 EFLAGS: 00010202
RAX: 0000000000000008 RBX: 00007f1af28410f0 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 00007f1af2840860
RBP: 00007f1af2840860 R08: 0000000000000001 R09: 0000000000000000
R10: 00000000200201c2 R11: 000000000001f7ad R12: 00007f1af28410f0
R13: 00007f1af29566d0 R14: 0000000000000003 R15: 00007ffed905b5c8
 </TASK>

Allocated by task 6132:
 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:3798 [inline]
 slab_alloc_node mm/slub.c:3845 [inline]
 kmem_cache_alloc+0x174/0x340 mm/slub.c:3852
 vm_area_alloc+0x24/0x1d0 kernel/fork.c:467
 mmap_region+0xd64/0x1e50 mm/mmap.c:2807
 do_mmap+0x7af/0xe60 mm/mmap.c:1385
 vm_mmap_pgoff+0x1e3/0x420 mm/util.c:573
 ksys_mmap_pgoff+0x53c/0x6e0 mm/mmap.c:1431
 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 15:
 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+0xa6/0xe0 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:2106 [inline]
 slab_free mm/slub.c:4280 [inline]
 kmem_cache_free+0x10b/0x2c0 mm/slub.c:4344
 rcu_do_batch kernel/rcu/tree.c:2196 [inline]
 rcu_core+0xafd/0x1830 kernel/rcu/tree.c:2471
 __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:2734 [inline]
 call_rcu+0x167/0xa70 kernel/rcu/tree.c:2838
 remove_vma mm/mmap.c:148 [inline]
 remove_mt mm/mmap.c:2289 [inline]
 do_vmi_align_munmap+0x15a7/0x1930 mm/mmap.c:2632
 do_vmi_munmap+0x24e/0x2d0 mm/mmap.c:2696
 mmap_region+0x6af/0x1e50 mm/mmap.c:2747
 do_mmap+0x7af/0xe60 mm/mmap.c:1385
 vm_mmap_pgoff+0x1e3/0x420 mm/util.c:573
 ksys_mmap_pgoff+0x53c/0x6e0 mm/mmap.c:1431
 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 ffff88801ed56000
 which belongs to the cache vm_area_struct of size 192
The buggy address is located 32 bytes inside of
 freed 192-byte region [ffff88801ed56000, ffff88801ed560c0)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1ed56
memcg:ffff888015149f01
ksm flags: 0xfff80000000800(slab|node=0|zone=1|lastcpupid=0xfff)
page_type: 0xffffffff()
raw: 00fff80000000800 ffff8880162a6b40 ffffea0001f65340 dead000000000007
raw: 0000000000000000 0000000000100010 00000001ffffffff ffff888015149f01
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 4739, tgid -1946949003 (dhcpcd), ts 4739, free_ts 49588172838
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1ea/0x210 mm/page_alloc.c:1534
 prep_new_page mm/page_alloc.c:1541 [inline]
 get_page_from_freelist+0x3410/0x35b0 mm/page_alloc.c:3317
 __alloc_pages+0x256/0x6c0 mm/page_alloc.c:4575
 __alloc_pages_node include/linux/gfp.h:238 [inline]
 alloc_pages_node include/linux/gfp.h:261 [inline]
 alloc_slab_page+0x5f/0x160 mm/slub.c:2175
 allocate_slab mm/slub.c:2338 [inline]
 new_slab+0x84/0x2f0 mm/slub.c:2391
 ___slab_alloc+0xc73/0x1260 mm/slub.c:3525
 __slab_alloc mm/slub.c:3610 [inline]
 __slab_alloc_node mm/slub.c:3663 [inline]
 slab_alloc_node mm/slub.c:3835 [inline]
 kmem_cache_alloc+0x252/0x340 mm/slub.c:3852
 vm_area_dup+0x27/0x290 kernel/fork.c:482
 dup_mmap kernel/fork.c:697 [inline]
 dup_mm kernel/fork.c:1688 [inline]
 copy_mm+0xd7f/0x2180 kernel/fork.c:1737
 copy_process+0x187a/0x3df0 kernel/fork.c:2390
 kernel_clone+0x223/0x870 kernel/fork.c:2797
 __do_sys_clone kernel/fork.c:2940 [inline]
 __se_sys_clone kernel/fork.c:2924 [inline]
 __x64_sys_clone+0x258/0x2a0 kernel/fork.c:2924
 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 4993 tgid 4993 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1141 [inline]
 free_unref_page_prepare+0x97b/0xaa0 mm/page_alloc.c:2347
 free_unref_folios+0x185/0xb30 mm/page_alloc.c:2536
 folios_put_refs+0x8eb/0xa10 mm/swap.c:1034
 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+0x4bb/0xd60 mm/mmap.c:3280
 __mmput+0x115/0x3c0 kernel/fork.c:1346
 exit_mm+0x220/0x310 kernel/exit.c:569
 do_exit+0x99e/0x27e0 kernel/exit.c:865
 do_group_exit+0x207/0x2c0 kernel/exit.c:1027
 __do_sys_exit_group kernel/exit.c:1038 [inline]
 __se_sys_exit_group kernel/exit.c:1036 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1036
 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:
 ffff88801ed55f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88801ed55f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88801ed56000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff88801ed56080: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff88801ed56100: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/04/21 14:24 upstream 977b1ef51866 af24b050 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-upstream-fs KASAN: slab-use-after-free Read in hugetlb_fault
2024/04/13 22:21 linux-next 9ed46da14b9b c8349e48 .config console log report syz C [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in hugetlb_fault
2024/04/24 12:01 upstream 9d1ddab261f3 21339d7b .config console log report syz [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: slab-use-after-free Read in hugetlb_fault
2024/04/20 18:06 upstream 13a2e429f644 af24b050 .config console log report syz [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: slab-use-after-free Read in hugetlb_fault
2024/05/11 13:31 upstream cf87f46fd34d 9026e142 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: slab-use-after-free Read in hugetlb_fault
2024/04/28 10:15 linux-next bb7a2467e6be 07b455f9 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in hugetlb_fault
* Struck through repros no longer work on HEAD.