syzbot


KASAN: use-after-free Write in ext4_insert_dentry

Status: upstream: reported C repro on 2024/11/30 15:43
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+c3bf43af1bfb618be15b@syzkaller.appspotmail.com
First crash: 30d, last: 20d
Bug presence (2)
Date Name Commit Repro Result
2024/11/30 lts (merge base) 0d968ced7330 C [report] KASAN: use-after-free Write in ext4_insert_dentry
2024/11/30 upstream (ToT) 2ba9f676d0a2 C [report] KASAN: use-after-free Write in ext4_insert_dentry
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-5-15 KASAN: use-after-free Write in ext4_insert_dentry origin:upstream C 8 12d 64d 0/2 upstream: reported C repro on 2024/10/27 00:37
android-5-10 KASAN: use-after-free Write in ext4_insert_dentry C 11 19d 107d 0/2 upstream: reported C repro on 2024/09/14 11:48
linux-5.15 KASAN: use-after-free Write in ext4_insert_dentry origin:upstream C 4 16d 30d 0/3 upstream: reported C repro on 2024/11/29 21:09
upstream KASAN: use-after-free Write in ext4_insert_dentry ext4 C done 64 10d 65d 0/28 upstream: reported C repro on 2024/10/25 22:56

Sample crash report:
loop0: detected capacity change from 0 to 512
EXT4-fs (loop0): 1 truncate cleaned up
EXT4-fs (loop0): mounted filesystem without journal. Quota mode: none.
==================================================================
BUG: KASAN: use-after-free in ext4_insert_dentry+0x389/0x720 fs/ext4/namei.c:2155
Write of size 254 at addr ffff888125e1bf0c by task syz-executor229/311

CPU: 1 PID: 311 Comm: syz-executor229 Not tainted 6.1.115-syzkaller-00007-g853ec04e2de4 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/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
 kasan_check_range+0x294/0x2a0 mm/kasan/generic.c:189
 memcpy+0x44/0x70 mm/kasan/shadow.c:66
 ext4_insert_dentry+0x389/0x720 fs/ext4/namei.c:2155
 add_dirent_to_buf+0x38c/0x780 fs/ext4/namei.c:2200
 make_indexed_dir+0xf29/0x1590 fs/ext4/namei.c:2398
 ext4_add_entry+0xbbf/0xed0 fs/ext4/namei.c:2504
 __ext4_link+0x4e9/0x790 fs/ext4/namei.c:3522
 ext4_link+0x1f3/0x290 fs/ext4/namei.c:3563
 vfs_link+0x645/0x7f0 fs/namei.c:4598
 do_linkat+0x34d/0x9f0 fs/namei.c:4669
 __do_sys_link fs/namei.c:4703 [inline]
 __se_sys_link fs/namei.c:4701 [inline]
 __x64_sys_link+0x86/0x90 fs/namei.c:4701
 x64_sys_call+0x282/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:87
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f2f80e431e9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 21 18 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:00007fff5fcf9ab8 EFLAGS: 00000246 ORIG_RAX: 0000000000000056
RAX: ffffffffffffffda RBX: 0030656c69662f2e RCX: 00007f2f80e431e9
RDX: 0000000000000000 RSI: 0000000020000bc0 RDI: 0000000020001240
RBP: 0000000020000000 R08: 00007fff5fcf9af0 R09: 00007fff5fcf9af0
R10: 00007fff5fcf9af0 R11: 0000000000000246 R12: 00007fff5fcf9adc
R13: 0000000000000001 R14: 431bde82d7b634db R15: 00007fff5fcf9b10
 </TASK>

The buggy address belongs to the physical page:
page:ffffea00049786c0 refcount:3 mapcount:0 mapping:ffff88810be650d0 index:0x3f pfn:0x125e1b
memcg:ffff888100332000
aops:def_blk_aops ino:700000
flags: 0x420000000000204a(referenced|dirty|workingset|private|zone=1)
raw: 420000000000204a 0000000000000000 dead000000000122 ffff88810be650d0
raw: 000000000000003f ffff8881239a8d20 00000003ffffffff ffff888100332000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Movable, gfp_mask 0x148c48(GFP_NOFS|__GFP_NOFAIL|__GFP_COMP|__GFP_HARDWALL|__GFP_MOVABLE), pid 311, tgid 311 (syz-executor229), ts 33419095410, free_ts 33388791572
 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+0x2980/0x2a10 mm/page_alloc.c:4439
 __alloc_pages+0x234/0x610 mm/page_alloc.c:5728
 __folio_alloc+0x15/0x40 mm/page_alloc.c:5760
 __folio_alloc_node include/linux/gfp.h:245 [inline]
 folio_alloc include/linux/gfp.h:274 [inline]
 filemap_alloc_folio include/linux/pagemap.h:513 [inline]
 __filemap_get_folio+0x827/0xae0 mm/filemap.c:2017
 pagecache_get_page+0x2f/0x110 mm/folio-compat.c:110
 find_or_create_page include/linux/pagemap.h:654 [inline]
 grow_dev_page fs/buffer.c:989 [inline]
 grow_buffers fs/buffer.c:1054 [inline]
 __getblk_slow fs/buffer.c:1081 [inline]
 __getblk_gfp+0x205/0x7d0 fs/buffer.c:1376
 sb_getblk include/linux/buffer_head.h:356 [inline]
 ext4_getblk+0x2a7/0x7b0 fs/ext4/inode.c:899
 ext4_bread+0x2f/0x180 fs/ext4/inode.c:945
 ext4_append+0x31f/0x5b0 fs/ext4/namei.c:83
 make_indexed_dir+0x518/0x1590 fs/ext4/namei.c:2318
 ext4_add_entry+0xbbf/0xed0 fs/ext4/namei.c:2504
 __ext4_link+0x4e9/0x790 fs/ext4/namei.c:3522
 ext4_link+0x1f3/0x290 fs/ext4/namei.c:3563
 vfs_link+0x645/0x7f0 fs/namei.c:4598
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:3511
 free_unref_page_list+0xf1/0x7b0 mm/page_alloc.c:3659
 release_pages+0xf7f/0xfe0 mm/swap.c:1063
 free_pages_and_swap_cache+0x8a/0xa0 mm/swap_state.c:315
 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
 unmap_region+0x2c1/0x310 mm/mmap.c:2403
 do_mas_align_munmap+0xd05/0x1400 mm/mmap.c:2670
 do_mas_munmap+0x23e/0x2b0 mm/mmap.c:2728
 __vm_munmap+0x263/0x3a0 mm/mmap.c:3018
 __do_sys_munmap mm/mmap.c:3044 [inline]
 __se_sys_munmap mm/mmap.c:3040 [inline]
 __x64_sys_munmap+0x6b/0x80 mm/mmap.c:3040
 x64_sys_call+0x75/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:12
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Memory state around the buggy address:
 ffff888125e1bf00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888125e1bf80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888125e1c000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                   ^
 ffff888125e1c080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888125e1c100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/12/09 23:15 android14-6.1 853ec04e2de4 9ac0fdc6 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-android-6-1 KASAN: use-after-free Write in ext4_insert_dentry
2024/11/30 16:12 android14-6.1 a887a44ace2a 68914665 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-android-6-1 KASAN: use-after-free Write in ext4_insert_dentry
2024/11/30 15:38 android14-6.1 a887a44ace2a 68914665 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-android-6-1 KASAN: use-after-free Write in ext4_insert_dentry
2024/11/30 15:05 android14-6.1 a887a44ace2a 68914665 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in ext4_insert_dentry
* Struck through repros no longer work on HEAD.