syzbot


KASAN: use-after-free Read in ext4_search_dir

Status: upstream: reported C repro on 2023/10/22 16:55
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+0d932da7cfedad13bd42@syzkaller.appspotmail.com
First crash: 193d, last: 3d16h
Cause bisection: failed (error log, bisect log)
  
Bug presence (2)
Date Name Commit Repro Result
2023/10/22 lts (merge base) b1644a0031cf C [report] KASAN: use-after-free Read in ext4_search_dir
2023/10/22 upstream (ToT) fe3cfe869d5e 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 7h50m 167d 0/2 upstream: reported C repro on 2023/11/17 09:38
linux-5.15 KASAN: use-after-free Read in ext4_search_dir origin:upstream C 1 19d 321d 0/3 upstream: reported C repro on 2023/06/16 15:52
android-54 KASAN: use-after-free Read in ext4_search_dir C 9 2d22h 17d 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 116d 357d 26/26 fixed on 2024/02/21 18:23
android-5-10 KASAN: slab-out-of-bounds Read in ext4_search_dir C 2 3d18h 167d 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 15d 319d 0/3 upstream: reported C repro on 2023/06/18 19:29
Last patch testing requests (3)
Created Duration User Patch Repo Result
2024/04/29 11:03 33m retest repro android14-6.1 report log
2024/04/07 10:37 5m retest repro android14-6.1 report log
2024/01/14 17:28 7m retest repro android14-6.1 report log
Fix bisection attempts (3)
Created Duration User Patch Repo Result
2024/03/24 09:02 42m bisect fix android14-6.1 job log (0) log
2024/02/23 06:58 46m bisect fix android14-6.1 job log (0) log
2023/12/31 12:51 1h01m bisect fix android14-6.1 job log (0) log

Sample crash report:
BUG: KASAN: use-after-free in ext4_search_dir+0xf7/0x1b0 fs/ext4/namei.c:1543
Read of size 1 at addr ffff8881104f96e3 by task syz-executor224/302

CPU: 1 PID: 302 Comm: syz-executor224 Not tainted 6.1.75-syzkaller-00023-gb76ed1185975 #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+0x151/0x1b7 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0x158/0x4e0 mm/kasan/report.c:427
 kasan_report+0x13c/0x170 mm/kasan/report.c:531
 __asan_report_load1_noabort+0x14/0x20 mm/kasan/report_generic.c:348
 ext4_search_dir+0xf7/0x1b0 fs/ext4/namei.c:1543
 ext4_find_inline_entry+0x4b6/0x5e0 fs/ext4/inline.c:1722
 __ext4_find_entry+0x2b0/0x1af0 fs/ext4/namei.c:1616
 ext4_lookup_entry fs/ext4/namei.c:1771 [inline]
 ext4_lookup+0x176/0x740 fs/ext4/namei.c:1839
 lookup_open fs/namei.c:3467 [inline]
 open_last_lookups fs/namei.c:3557 [inline]
 path_openat+0x10fd/0x2d60 fs/namei.c:3787
 do_filp_open+0x230/0x480 fs/namei.c:3817
 do_sys_openat2+0x13f/0x850 fs/open.c:1341
 do_sys_open fs/open.c:1357 [inline]
 __do_sys_openat fs/open.c:1373 [inline]
 __se_sys_openat fs/open.c:1368 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1368
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7facb787c109
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 01 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff7498b328 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 0030656c69662f2e RCX: 00007facb787c109
RDX: 000000000000275a RSI: 0000000020000280 RDI: 00000000ffffff9c
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fff7498b5c0
R13: 0000000000000000 R14: 431bde82d7b634db R15: 00007fff7498b390
 </TASK>

The buggy address belongs to the physical page:
page:ffffea0004413e40 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x1104f9
flags: 0x4000000000000000(zone=1)
raw: 4000000000000000 ffffea00043e28c8 ffffea0004565788 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 0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), pid 301, tgid 301 (syz-executor224), ts 19976640089, free_ts 20254560752
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x213/0x220 mm/page_alloc.c:2590
 prep_new_page+0x1b/0x110 mm/page_alloc.c:2597
 get_page_from_freelist+0x27ea/0x2870 mm/page_alloc.c:4425
 __alloc_pages+0x3a1/0x780 mm/page_alloc.c:5712
 __folio_alloc+0x15/0x40 mm/page_alloc.c:5744
 __folio_alloc_node include/linux/gfp.h:245 [inline]
 folio_alloc include/linux/gfp.h:274 [inline]
 alloc_page_vma include/linux/gfp.h:283 [inline]
 wp_page_copy+0x261/0x1690 mm/memory.c:3179
 do_wp_page+0xc25/0xdf0
 handle_pte_fault mm/memory.c:5113 [inline]
 __handle_mm_fault mm/memory.c:5237 [inline]
 handle_mm_fault+0x15a2/0x2f40 mm/memory.c:5377
 do_user_addr_fault arch/x86/mm/fault.c:1363 [inline]
 handle_page_fault arch/x86/mm/fault.c:1506 [inline]
 exc_page_fault+0x3b3/0x700 arch/x86/mm/fault.c:1562
 asm_exc_page_fault+0x27/0x30 arch/x86/include/asm/idtentry.h:570
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1498 [inline]
 free_pcp_prepare mm/page_alloc.c:1572 [inline]
 free_unref_page_prepare+0x83d/0x850 mm/page_alloc.c:3498
 free_unref_page_list+0xf1/0x7b0 mm/page_alloc.c:3646
 release_pages+0xf7f/0xfe0 mm/swap.c:1063
 free_pages_and_swap_cache+0x8a/0xa0 mm/swap_state.c:314
 tlb_batch_pages_flush mm/mmu_gather.c:59 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:254 [inline]
 tlb_flush_mmu mm/mmu_gather.c:261 [inline]
 tlb_finish_mmu+0x1e0/0x3f0 mm/mmu_gather.c:361
 exit_mmap+0x421/0x940 mm/mmap.c:3343
 __mmput+0x95/0x310 kernel/fork.c:1298
 mmput+0x56/0x170 kernel/fork.c:1321
 exit_mm kernel/exit.c:566 [inline]
 do_exit+0xb29/0x2b80 kernel/exit.c:862
 do_group_exit+0x21a/0x2d0 kernel/exit.c:1025
 __do_sys_exit_group kernel/exit.c:1036 [inline]
 __se_sys_exit_group kernel/exit.c:1034 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1034
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Memory state around the buggy address:
 ffff8881104f9580: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff8881104f9600: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff8881104f9680: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                                       ^
 ffff8881104f9700: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff8881104f9780: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================
EXT4-fs error (device loop3): ext4_find_dest_de:2112: inode #12: block 5: comm syz-executor224: bad entry in directory: rec_len % 4 != 0 - offset=0, inode=1375716473, rec_len=40042, size=56 fake=0

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/04/15 09:34 android14-6.1 b76ed1185975 c8349e48 .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-android-6-1 KASAN: use-after-free Read in ext4_search_dir
2023/11/17 09:50 android14-6.1 b496cc311544 cb976f63 .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci2-android-6-1 KASAN: use-after-free Read in ext4_search_dir
2023/10/22 16:54 android14-6.1 53771c1826da 361b23dc .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci2-android-6-1 KASAN: use-after-free Read in ext4_search_dir
* Struck through repros no longer work on HEAD.