syzbot


KASAN: use-after-free Read in ptdump_pte_entry

Status: upstream: reported on 2025/01/20 16:49
Subsystems: mm
[Documentation on labels]
Reported-by: syzbot+5de79efe17a3a69f3f42@syzkaller.appspotmail.com
First crash: 32d, last: 4d23h
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [mm?] KASAN: use-after-free Read in ptdump_pte_entry 0 (1) 2025/01/20 16:49

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in ptep_get include/linux/pgtable.h:338 [inline]
BUG: KASAN: use-after-free in ptep_get_lockless include/linux/pgtable.h:615 [inline]
BUG: KASAN: use-after-free in ptdump_pte_entry+0xf6/0x100 mm/ptdump.c:123
Read of size 8 at addr ffff888068d912b0 by task syz.1.2174/17512

CPU: 0 UID: 0 PID: 17512 Comm: syz.1.2174 Not tainted 6.14.0-rc1-syzkaller-00020-g0de63bb7d919 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:378 [inline]
 print_report+0xc3/0x620 mm/kasan/report.c:489
 kasan_report+0xd9/0x110 mm/kasan/report.c:602
 ptep_get include/linux/pgtable.h:338 [inline]
 ptep_get_lockless include/linux/pgtable.h:615 [inline]
 ptdump_pte_entry+0xf6/0x100 mm/ptdump.c:123
 walk_pte_range_inner+0x256/0x360 mm/pagewalk.c:50
 walk_pte_range mm/pagewalk.c:81 [inline]
 walk_pmd_range mm/pagewalk.c:156 [inline]
 walk_pud_range mm/pagewalk.c:226 [inline]
 walk_p4d_range mm/pagewalk.c:264 [inline]
 walk_pgd_range+0xfe4/0x1a70 mm/pagewalk.c:305
 walk_page_range_novma+0x1b5/0x260 mm/pagewalk.c:648
 ptdump_walk_pgd+0x124/0x330 mm/ptdump.c:158
 ptdump_walk_pgd_level_core+0x15f/0x220 arch/x86/mm/dump_pagetables.c:391
 ptdump_curknl_show arch/x86/mm/debug_pagetables.c:19 [inline]
 ptdump_curknl_show+0x9f/0xd0 arch/x86/mm/debug_pagetables.c:16
 traverse.part.0.constprop.0+0x104/0x640 fs/seq_file.c:111
 traverse fs/seq_file.c:98 [inline]
 seq_read_iter+0x934/0x12b0 fs/seq_file.c:195
 seq_read+0x39f/0x4e0 fs/seq_file.c:162
 full_proxy_read+0x13c/0x200 fs/debugfs/file.c:393
 vfs_read+0x1df/0xbf0 fs/read_write.c:563
 ksys_pread64 fs/read_write.c:756 [inline]
 __do_sys_pread64 fs/read_write.c:764 [inline]
 __se_sys_pread64 fs/read_write.c:761 [inline]
 __x64_sys_pread64+0x1f6/0x250 fs/read_write.c:761
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f7b7a38cda9
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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f7b7b182038 EFLAGS: 00000246 ORIG_RAX: 0000000000000011
RAX: ffffffffffffffda RBX: 00007f7b7a5a5fa0 RCX: 00007f7b7a38cda9
RDX: 0000080100000001 RSI: 0000000000000000 RDI: 0000000000000007
RBP: 00007f7b7a40e2a0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000101 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f7b7a5a5fa0 R15: 00007ffc9f4ffde8
 </TASK>

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x68d91
memcg:ffff888021f81982
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
page_type: f2(table)
raw: 00fff00000000000 0000000000000000 dead000000000122 0000000000000000
raw: 0000000000000000 ffff88805e479240 00000001f2000000 ffff888021f81982
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x440dc0(GFP_KERNEL_ACCOUNT|__GFP_COMP|__GFP_ZERO), pid 17584, tgid 17584 (syz.6.2185), ts 688097808363, free_ts 688063977434
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x181/0x1b0 mm/page_alloc.c:1551
 prep_new_page mm/page_alloc.c:1559 [inline]
 get_page_from_freelist+0xfce/0x2f80 mm/page_alloc.c:3477
 __alloc_frozen_pages_noprof+0x221/0x2470 mm/page_alloc.c:4739
 alloc_pages_mpol+0x1fc/0x540 mm/mempolicy.c:2270
 alloc_frozen_pages_noprof mm/mempolicy.c:2341 [inline]
 alloc_pages_noprof+0x131/0x390 mm/mempolicy.c:2361
 pagetable_alloc_noprof include/linux/mm.h:2900 [inline]
 __pte_alloc_one_noprof include/asm-generic/pgalloc.h:70 [inline]
 pte_alloc_one+0x20/0x390 arch/x86/mm/pgtable.c:44
 __do_fault+0x320/0x490 mm/memory.c:4972
 do_shared_fault mm/memory.c:5456 [inline]
 do_fault mm/memory.c:5530 [inline]
 do_pte_missing+0x1a8/0x3e10 mm/memory.c:4047
 handle_pte_fault mm/memory.c:5889 [inline]
 __handle_mm_fault+0x1166/0x2c60 mm/memory.c:6032
 handle_mm_fault+0x3fa/0xaa0 mm/memory.c:6201
 do_user_addr_fault+0x60d/0x13f0 arch/x86/mm/fault.c:1337
 handle_page_fault arch/x86/mm/fault.c:1480 [inline]
 exc_page_fault+0x5c/0xc0 arch/x86/mm/fault.c:1538
 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623
page last free pid 17585 tgid 17584 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1127 [inline]
 free_frozen_pages+0x6db/0xfb0 mm/page_alloc.c:2660
 pmd_free_pte_page+0xb0/0xe0 arch/x86/mm/pgtable.c:886
 vmap_try_huge_pmd mm/vmalloc.c:153 [inline]
 vmap_pmd_range mm/vmalloc.c:172 [inline]
 vmap_pud_range mm/vmalloc.c:228 [inline]
 vmap_p4d_range mm/vmalloc.c:279 [inline]
 vmap_range_noflush+0x579/0x1060 mm/vmalloc.c:303
 __vmap_pages_range_noflush+0x104/0x700 mm/vmalloc.c:621
 vmap_pages_range_noflush mm/vmalloc.c:641 [inline]
 vmap_pages_range mm/vmalloc.c:661 [inline]
 __vmalloc_area_node mm/vmalloc.c:3713 [inline]
 __vmalloc_node_range_noprof+0xbb5/0x1530 mm/vmalloc.c:3846
 __kvmalloc_node_noprof+0x14f/0x1a0 mm/util.c:684
 kvmalloc_array_node_noprof include/linux/slab.h:1063 [inline]
 __do_sys_listmount+0x1bf/0xeb0 fs/namespace.c:5642
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
 ffff888068d91180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888068d91200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888068d91280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                     ^
 ffff888068d91300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888068d91380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/02/04 12:22 upstream 0de63bb7d919 8f267cef .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: use-after-free Read in ptdump_pte_entry
2025/01/07 18:58 upstream fbfd64d25c7a f3558dbf .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: use-after-free Read in ptdump_pte_entry
* Struck through repros no longer work on HEAD.