syzbot


KASAN: use-after-free Read in __ext4_check_dir_entry

Status: upstream: reported C repro on 2024/06/03 01:15
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+618531929d48e32a4823@syzkaller.appspotmail.com
First crash: 16d, last: 10d
Bug presence (1)
Date Name Commit Repro Result
2024/06/03 upstream (ToT) c3f38fa61af7 C [report] KASAN: use-after-free Read in __ext4_check_dir_entry
Similar bugs (7)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Read in __ext4_check_dir_entry C inconclusive 6 1365d 1468d 0/1 upstream: reported C repro on 2020/06/12 02:23
upstream KASAN: use-after-free Read in __ext4_check_dir_entry (2) ext4 C error 1 26d 36d 0/27 upstream: reported C repro on 2024/05/14 14:09
android-5-15 KASAN: use-after-free Read in __ext4_check_dir_entry 1 5d02h 5d02h 0/2 premoderation: reported on 2024/06/14 16:50
upstream KASAN: use-after-free Read in __ext4_check_dir_entry ext4 C 8 2269d 2271d 22/27 closed as dup on 2018/03/31 22:38
android-5-10 KASAN: use-after-free Read in __ext4_check_dir_entry C 1 26d 40d 0/2 upstream: reported C repro on 2024/05/10 09:19
android-6-1 KASAN: use-after-free Read in __ext4_check_dir_entry origin:upstream C 4 18d 39d 0/2 upstream: reported C repro on 2024/05/11 11:53
linux-6.1 KASAN: use-after-free Read in __ext4_check_dir_entry 6 10d 16d 0/3 upstream: reported on 2024/06/03 01:12

Sample crash report:
EXT4-fs warning (device loop0): dx_probe:965: inode #2: comm syz-executor581: Corrupt directory, running e2fsck is recommended
==================================================================
BUG: KASAN: use-after-free in __ext4_check_dir_entry+0x6f3/0x870 fs/ext4/dir.c:85
Read of size 2 at addr ffff8880708f6003 by task syz-executor581/3513

CPU: 1 PID: 3513 Comm: syz-executor581 Not tainted 5.15.160-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/02/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
 print_address_description+0x63/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
 __ext4_check_dir_entry+0x6f3/0x870 fs/ext4/dir.c:85
 ext4_readdir+0x14a6/0x38e0 fs/ext4/dir.c:258
 iterate_dir+0x224/0x570
 __do_sys_getdents64 fs/readdir.c:369 [inline]
 __se_sys_getdents64+0x209/0x4f0 fs/readdir.c:354
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7fa96dc1e569
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 61 1b 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:00007fa96dbd0218 EFLAGS: 00000246 ORIG_RAX: 00000000000000d9
RAX: ffffffffffffffda RBX: 00007fa96dc9e608 RCX: 00007fa96dc1e569
RDX: 0000000000000010 RSI: 0000000000000000 RDI: 0000000000000008
RBP: 00007fa96dc9e600 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fa96dc6b62c
R13: 00007fa96dc6b2e0 R14: 00007fa96dc6b528 R15: 6f6f6c2f7665642f
 </TASK>

The buggy address belongs to the page:
page:ffffea0001c23d80 refcount:1 mapcount:1 mapping:0000000000000000 index:0x55b157b7a pfn:0x708f6
memcg:ffff888011e84000
anon flags: 0xfff00000080014(uptodate|lru|swapbacked|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000080014 ffffea0001589b48 ffffea0001c23dc8 ffff88801a9ea771
raw: 000000055b157b7a 0000000000000000 0000000100000000 ffff888011e84000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Movable, gfp_mask 0x1100cca(GFP_HIGHUSER_MOVABLE), pid 2964, ts 43131601451, free_ts 37232586833
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x322a/0x33c0 mm/page_alloc.c:4159
 __alloc_pages+0x272/0x700 mm/page_alloc.c:5423
 alloc_pages_vma+0x39a/0x800 mm/mempolicy.c:2146
 wp_page_copy+0x24e/0x2070 mm/memory.c:3026
 handle_pte_fault mm/memory.c:4639 [inline]
 __handle_mm_fault mm/memory.c:4756 [inline]
 handle_mm_fault+0x2a3d/0x5950 mm/memory.c:4854
 do_user_addr_fault arch/x86/mm/fault.c:1388 [inline]
 handle_page_fault arch/x86/mm/fault.c:1476 [inline]
 exc_page_fault+0x271/0x740 arch/x86/mm/fault.c:1532
 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:568
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare mm/page_alloc.c:1391 [inline]
 free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
 free_unref_page_list+0x1f7/0x8e0 mm/page_alloc.c:3433
 release_pages+0x1bb9/0x1f40 mm/swap.c:963
 tlb_batch_pages_flush mm/mmu_gather.c:49 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:240 [inline]
 tlb_flush_mmu mm/mmu_gather.c:247 [inline]
 tlb_finish_mmu+0x177/0x320 mm/mmu_gather.c:338
 exit_mmap+0x3cd/0x670 mm/mmap.c:3188
 __mmput+0x112/0x3b0 kernel/fork.c:1126
 exit_mm+0x688/0x7f0 kernel/exit.c:548
 do_exit+0x626/0x2480 kernel/exit.c:859
 do_group_exit+0x144/0x310 kernel/exit.c:994
 __do_sys_exit_group kernel/exit.c:1005 [inline]
 __se_sys_exit_group kernel/exit.c:1003 [inline]
 __x64_sys_exit_group+0x3b/0x40 kernel/exit.c:1003
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Memory state around the buggy address:
 ffff8880708f5f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880708f5f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8880708f6000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                   ^
 ffff8880708f6080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880708f6100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (8):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/06/03 01:49 linux-5.15.y c61bd26ae81a 3113787f .config console log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-5-15-kasan KASAN: use-after-free Read in __ext4_check_dir_entry
2024/06/08 20:27 linux-5.15.y c61bd26ae81a 82c05ab8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in __ext4_check_dir_entry
2024/06/08 20:26 linux-5.15.y c61bd26ae81a 82c05ab8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in __ext4_check_dir_entry
2024/06/03 01:21 linux-5.15.y c61bd26ae81a 3113787f .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in __ext4_check_dir_entry
2024/06/03 01:18 linux-5.15.y c61bd26ae81a 3113787f .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in __ext4_check_dir_entry
2024/06/03 01:17 linux-5.15.y c61bd26ae81a 3113787f .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in __ext4_check_dir_entry
2024/06/03 01:16 linux-5.15.y c61bd26ae81a 3113787f .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in __ext4_check_dir_entry
2024/06/03 01:14 linux-5.15.y c61bd26ae81a 3113787f .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in __ext4_check_dir_entry
* Struck through repros no longer work on HEAD.