syzbot


KASAN: use-after-free Write in ext4_insert_dentry

Status: upstream: reported C repro on 2024/10/25 22:56
Subsystems: ext4
[Documentation on labels]
Reported-by: syzbot+0c99c3f90699936c1e77@syzkaller.appspotmail.com
First crash: 30d, last: 2d00h
Cause bisection: introduced by (bisect log) :
commit 5872331b3d91820e14716632ebb56b1399b34fe1
Author: Eric Sandeen <sandeen@redhat.com>
Date: Wed Jun 17 19:19:04 2020 +0000

  ext4: fix potential negative array index in do_split()

Crash: KASAN: use-after-free Write in add_dirent_to_buf (log)
Repro: C syz .config
  
Discussions (2)
Title Replies (including bot) Last reply
[syzbot] [ext4?] KASAN: use-after-free Write in ext4_insert_dentry 5 (12) 2024/11/06 15:22
[PATCH] ext4: Add a sanity check for next dentry when insert 6 (6) 2024/11/04 06:43
Similar bugs (2)
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 5 2d23h 25d 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 2 18d 67d 0/2 upstream: reported C repro on 2024/09/14 11:48
Last patch testing requests (5)
Created Duration User Patch Repo Result
2024/10/30 11:21 12m eadavis@qq.com patch upstream error
2024/10/27 10:27 12m eadavis@qq.com patch upstream error
2024/10/27 09:51 9m eadavis@qq.com patch upstream error
2024/10/27 08:54 19m eadavis@qq.com patch upstream OK log
2024/10/27 04:53 13m eadavis@qq.com patch upstream report log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in ext4_insert_dentry+0x36a/0x6d0 fs/ext4/namei.c:2109
Write of size 251 at addr ffff888074572f14 by task syz-executor335/5847

CPU: 0 UID: 0 PID: 5847 Comm: syz-executor335 Not tainted 6.12.0-rc6-syzkaller-00318-ga9cda7c0ffed #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/30/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report+0x143/0x180 mm/kasan/report.c:601
 kasan_check_range+0x282/0x290 mm/kasan/generic.c:189
 __asan_memcpy+0x40/0x70 mm/kasan/shadow.c:106
 ext4_insert_dentry+0x36a/0x6d0 fs/ext4/namei.c:2109
 add_dirent_to_buf+0x3d9/0x750 fs/ext4/namei.c:2154
 make_indexed_dir+0xf98/0x1600 fs/ext4/namei.c:2351
 ext4_add_entry+0x222a/0x25d0 fs/ext4/namei.c:2455
 ext4_add_nondir+0x8d/0x290 fs/ext4/namei.c:2796
 ext4_symlink+0x920/0xb50 fs/ext4/namei.c:3431
 vfs_symlink+0x137/0x2e0 fs/namei.c:4615
 do_symlinkat+0x222/0x3a0 fs/namei.c:4641
 __do_sys_symlink fs/namei.c:4662 [inline]
 __se_sys_symlink fs/namei.c:4660 [inline]
 __x64_sys_symlink+0x7a/0x90 fs/namei.c:4660
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fce8c3ec229
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:00007ffec7eb3138 EFLAGS: 00000246 ORIG_RAX: 0000000000000058
RAX: ffffffffffffffda RBX: 0030656c69662f2e RCX: 00007fce8c3ec229
RDX: 0000000000000000 RSI: 0000000020000cc0 RDI: 0000000020000dc0
RBP: 0000000000000000 R08: 00007ffec7eb3170 R09: 00007ffec7eb3170
R10: 00007ffec7eb3170 R11: 0000000000000246 R12: 00007ffec7eb315c
R13: 0000000000000007 R14: 431bde82d7b634db R15: 00007ffec7eb3190
 </TASK>

The buggy address belongs to the physical page:
page: refcount:3 mapcount:0 mapping:ffff8880235841f8 index:0x3f pfn:0x74572
memcg:ffff88801bed4000
aops:def_blk_aops ino:700000 dentry name(?):""
flags: 0xfff00000004114(referenced|dirty|active|private|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000004114 0000000000000000 dead000000000122 ffff8880235841f8
raw: 000000000000003f ffff888073c9c2b8 00000003ffffffff ffff88801bed4000
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 5847, tgid 5847 (syz-executor335), ts 63877497829, free_ts 55876680526
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1541
 prep_new_page mm/page_alloc.c:1549 [inline]
 get_page_from_freelist+0x363e/0x3790 mm/page_alloc.c:3459
 __alloc_pages_noprof+0x292/0x710 mm/page_alloc.c:4735
 alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2265
 alloc_pages_noprof mm/mempolicy.c:2345 [inline]
 folio_alloc_noprof+0x128/0x180 mm/mempolicy.c:2352
 filemap_alloc_folio_noprof+0xdf/0x500 mm/filemap.c:1010
 __filemap_get_folio+0x446/0xbd0 mm/filemap.c:1952
 grow_dev_folio fs/buffer.c:1043 [inline]
 grow_buffers fs/buffer.c:1109 [inline]
 __getblk_slow fs/buffer.c:1135 [inline]
 bdev_getblk+0x1d8/0x550 fs/buffer.c:1437
 __getblk include/linux/buffer_head.h:380 [inline]
 sb_getblk include/linux/buffer_head.h:386 [inline]
 ext4_getblk+0x303/0x800 fs/ext4/inode.c:859
 ext4_bread+0x2e/0x180 fs/ext4/inode.c:905
 ext4_append+0x327/0x5c0 fs/ext4/namei.c:83
 make_indexed_dir+0x523/0x1600 fs/ext4/namei.c:2272
 ext4_add_entry+0x222a/0x25d0 fs/ext4/namei.c:2455
 ext4_add_nondir+0x8d/0x290 fs/ext4/namei.c:2796
 ext4_symlink+0x920/0xb50 fs/ext4/namei.c:3431
 vfs_symlink+0x137/0x2e0 fs/namei.c:4615
page last free pid 5821 tgid 5821 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1112 [inline]
 free_unref_folios+0xd83/0x1720 mm/page_alloc.c:2689
 folios_put_refs+0x76c/0x860 mm/swap.c:1007
 free_pages_and_swap_cache+0x2ea/0x690 mm/swap_state.c:332
 __tlb_batch_free_encoded_pages mm/mmu_gather.c:136 [inline]
 tlb_batch_pages_flush mm/mmu_gather.c:149 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:366 [inline]
 tlb_flush_mmu+0x3a3/0x680 mm/mmu_gather.c:373
 tlb_finish_mmu+0xd4/0x200 mm/mmu_gather.c:465
 exit_mmap+0x496/0xc40 mm/mmap.c:1936
 __mmput+0x115/0x380 kernel/fork.c:1348
 exit_mm+0x220/0x310 kernel/exit.c:571
 do_exit+0x9b2/0x28e0 kernel/exit.c:926
 do_group_exit+0x207/0x2c0 kernel/exit.c:1088
 __do_sys_exit_group kernel/exit.c:1099 [inline]
 __se_sys_exit_group kernel/exit.c:1097 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1097
 x64_sys_call+0x2634/0x2640 arch/x86/include/generated/asm/syscalls_64.h:232
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
 ffff888074572f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888074572f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888074573000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                   ^
 ffff888074573080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888074573100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (39):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/10 22:02 upstream a9cda7c0ffed 6b856513 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-upstream-fs KASAN: use-after-free Write in ext4_insert_dentry
2024/11/10 00:34 upstream de2f378f2b77 6b856513 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-upstream-fs KASAN: use-after-free Write in ext4_insert_dentry
2024/11/09 21:30 upstream da4373fbcf00 6b856513 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-upstream-fs KASAN: use-after-free Write in ext4_insert_dentry
2024/11/09 20:41 upstream da4373fbcf00 6b856513 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-upstream-fs KASAN: use-after-free Write in ext4_insert_dentry
2024/11/06 06:35 upstream 2e1b3cc9d7f7 3a465482 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-upstream-fs KASAN: use-after-free Write in ext4_insert_dentry
2024/10/21 23:29 upstream 42f7652d3eb5 14517542 .config console log report syz / log C [disk image (non-bootable)] [vmlinux] [kernel image] [mounted in repro] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/11/10 22:37 upstream a9cda7c0ffed 6b856513 .config console log report syz / log [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-upstream-fs KASAN: out-of-bounds Write in ext4_insert_dentry
2024/11/17 01:16 upstream e8bdb3c8be08 cfe3a04a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: use-after-free Write in ext4_insert_dentry
2024/11/02 17:43 upstream 11066801dd4b f00eed24 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Write in ext4_insert_dentry
2024/11/19 06:30 upstream 9fb2cfa4635a 571351cb .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/11/13 07:34 upstream 3022e9d00ebe 62026c85 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/11/11 05:29 upstream a9cda7c0ffed 6b856513 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/11/10 07:18 upstream de2f378f2b77 6b856513 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/11/10 06:14 upstream de2f378f2b77 6b856513 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/11/08 15:45 upstream 906bd684e4b1 d40c056e .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/11/05 19:10 upstream 2e1b3cc9d7f7 da38b4c9 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/11/05 08:12 upstream 557329bcecc2 509da429 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/11/04 23:56 upstream 59b723cd2adb 0754ea12 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/11/02 10:32 upstream 11066801dd4b f00eed24 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/11/02 09:18 upstream 11066801dd4b f00eed24 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/11/01 23:05 upstream 6c52d4da1c74 f00eed24 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/11/01 21:51 upstream 6c52d4da1c74 f00eed24 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/10/31 12:32 upstream 0fc810ae3ae1 96eb609f .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/10/31 05:19 upstream 4236f913808c fb888278 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/10/29 16:18 upstream e42b1a9a2557 66aeb999 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/10/28 22:36 upstream 819837584309 9efb3cc7 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/10/27 19:22 upstream 850925a8133c 65e8686b .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/10/27 11:15 upstream 850925a8133c 65e8686b .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/10/27 10:30 upstream 850925a8133c 65e8686b .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/10/27 05:29 upstream 850925a8133c 65e8686b .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/10/26 18:58 upstream 850925a8133c 65e8686b .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/10/25 20:03 upstream ae90f6a6170d 2a61f980 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/10/25 12:18 upstream ae90f6a6170d 2a61f980 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/10/25 04:18 upstream 4e46774408d9 c79b8ca5 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/10/23 15:50 upstream c2ee9f594da8 15fa2979 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/10/23 14:48 upstream c2ee9f594da8 15fa2979 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/10/23 12:07 upstream c2ee9f594da8 15fa2979 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/10/22 02:00 upstream c2ee9f594da8 a93682b3 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
2024/10/21 22:46 upstream 42f7652d3eb5 14517542 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Write in ext4_insert_dentry
* Struck through repros no longer work on HEAD.