syzbot


KASAN: use-after-free Read in ext4_search_dir

Status: upstream: reported C repro on 2023/06/16 15:52
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+49e1219c6cb561ada5b9@syzkaller.appspotmail.com
First crash: 325d, last: 23d
Bug presence (1)
Date Name Commit Repro Result
2023/06/16 upstream (ToT) 4973ca295528 C [report] KASAN: use-after-free Read in ext4_search_dir
Similar bugs (6)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-5-15 KASAN: slab-out-of-bounds Read in ext4_search_dir origin:upstream C 2 4d08h 171d 0/2 upstream: reported C repro on 2023/11/17 09:38
android-54 KASAN: use-after-free Read in ext4_search_dir C 9 6d22h 21d 0/2 upstream: reported C repro on 2024/04/15 06:47
upstream KASAN: use-after-free Read in ext4_search_dir prio:low ext4 C error done 20 120d 361d 26/26 fixed on 2024/02/21 18:23
android-6-1 KASAN: use-after-free Read in ext4_search_dir origin:upstream C error 3 7d16h 197d 0/2 upstream: reported C repro on 2023/10/22 16:55
android-5-10 KASAN: slab-out-of-bounds Read in ext4_search_dir C 2 7d18h 171d 0/2 upstream: reported C repro on 2023/11/17 09:38
linux-6.1 KASAN: use-after-free Read in ext4_search_dir origin:upstream C 1 19d 323d 0/3 upstream: reported C repro on 2023/06/18 19:29
Fix bisection attempts (8)
Created Duration User Patch Repo Result
2024/04/13 21:39 1h13m bisect fix linux-5.15.y job log (0) log
2024/03/11 19:15 48m bisect fix linux-5.15.y job log (0) log
2024/02/05 10:49 1h18m bisect fix linux-5.15.y job log (0) log
2023/12/31 21:15 54m bisect fix linux-5.15.y job log (0) log
2023/12/01 16:17 56m bisect fix linux-5.15.y job log (0) log
2023/10/31 04:00 1h08m bisect fix linux-5.15.y job log (0) log
2023/09/30 18:26 52m bisect fix linux-5.15.y job log (0) log
2023/07/31 13:44 1h22m bisect fix linux-5.15.y job log (0) log

Sample crash report:
EXT4-fs (loop0): 1 truncate cleaned up
EXT4-fs (loop0): mounted filesystem without journal. Opts: jqfmt=vfsold,resgid=0x000000000000ee00,bh,noload,data_err=ignore,usrjquota=,,errors=continue. Quota mode: none.
==================================================================
BUG: KASAN: use-after-free in ext4_search_dir+0xee/0x1b0 fs/ext4/namei.c:1539
Read of size 1 at addr ffff888070d8f3ed by task syz-executor168/3509

CPU: 0 PID: 3509 Comm: syz-executor168 Not tainted 5.15.117-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb 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_search_dir+0xee/0x1b0 fs/ext4/namei.c:1539
 ext4_find_inline_entry+0x4b6/0x5e0 fs/ext4/inline.c:1700
 __ext4_find_entry+0x2b0/0x1b20 fs/ext4/namei.c:1612
 ext4_lookup_entry fs/ext4/namei.c:1767 [inline]
 ext4_lookup+0x3c6/0xaa0 fs/ext4/namei.c:1835
 lookup_open fs/namei.c:3370 [inline]
 open_last_lookups fs/namei.c:3462 [inline]
 path_openat+0x110e/0x2f20 fs/namei.c:3669
 do_filp_open+0x21c/0x460 fs/namei.c:3699
 do_sys_openat2+0x13b/0x500 fs/open.c:1211
 do_sys_open fs/open.c:1227 [inline]
 __do_sys_open fs/open.c:1235 [inline]
 __se_sys_open fs/open.c:1231 [inline]
 __x64_sys_open+0x221/0x270 fs/open.c:1231
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7f5fc9455cf9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 11 15 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff59a4b7e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 000000000000dd5c RCX: 00007f5fc9455cf9
RDX: 0000000000000000 RSI: 0000000000141042 RDI: 0000000020000100
RBP: 0000000000000000 R08: 000000000001f210 R09: 00000000200012c0
R10: 00007f5fb8c48000 R11: 0000000000000246 R12: 00007fff59a4b81c
R13: 00007fff59a4b850 R14: 00007fff59a4b830 R15: 0000000000000004
 </TASK>

The buggy address belongs to the page:
page:ffffea0001c363c0 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x70d8f
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 ffffea0001c36408 ffffea0001c36388 0000000000000000
raw: 0000000000000001 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 0, migratetype Movable, gfp_mask 0x1100dca(GFP_HIGHUSER_MOVABLE|__GFP_ZERO), pid 3507, ts 56768897628, free_ts 56796369712
 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:5421
 alloc_pages_vma+0x39a/0x800 mm/mempolicy.c:2146
 do_anonymous_page mm/memory.c:3795 [inline]
 handle_pte_fault mm/memory.c:4606 [inline]
 __handle_mm_fault mm/memory.c:4743 [inline]
 handle_mm_fault+0x2f49/0x5950 mm/memory.c:4841
 do_user_addr_fault arch/x86/mm/fault.c:1397 [inline]
 handle_page_fault arch/x86/mm/fault.c:1485 [inline]
 exc_page_fault+0x271/0x740 arch/x86/mm/fault.c:1541
 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
 unmap_region+0x304/0x350 mm/mmap.c:2668
 __do_munmap+0x12db/0x1740 mm/mmap.c:2899
 __vm_munmap+0x134/0x230 mm/mmap.c:2922
 __do_sys_munmap mm/mmap.c:2948 [inline]
 __se_sys_munmap mm/mmap.c:2944 [inline]
 __x64_sys_munmap+0x67/0x70 mm/mmap.c:2944
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Memory state around the buggy address:
 ffff888070d8f280: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888070d8f300: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888070d8f380: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                                          ^
 ffff888070d8f400: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888070d8f480: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/06/16 15:51 linux-5.15.y 471e639e59d1 f3921d4d .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci2-linux-5-15-kasan KASAN: use-after-free Read in ext4_search_dir
* Struck through repros no longer work on HEAD.