[Android 6.1] KASAN: use-after-free Write in ext4_insert_dentry

6 views
Skip to first unread message

syzbot

unread,
Nov 30, 2024, 10:43:29 AM11/30/24
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: a887a44ace2a ANDROID: KVM: arm64: Always check state from ..
git tree: android14-6.1
console+strace: https://syzkaller.appspot.com/x/log.txt?x=15dc00df980000
kernel config: https://syzkaller.appspot.com/x/.config?x=c1a81d4ee887f8df
dashboard link: https://syzkaller.appspot.com/bug?extid=c3bf43af1bfb618be15b
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11369f78580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17c779e8580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/829193ad66a2/disk-a887a44a.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/2a40f2669379/vmlinux-a887a44a.xz
kernel image: https://storage.googleapis.com/syzbot-assets/0267d8684dee/bzImage-a887a44a.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/b735f16cd2af/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+c3bf43...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in ext4_insert_dentry+0x389/0x720 fs/ext4/namei.c:2155
Write of size 250 at addr ffff8881152dcf18 by task syz-executor167/298

CPU: 1 PID: 298 Comm: syz-executor167 Not tainted 6.1.115-syzkaller-00041-ga887a44ace2a #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_mkdir+0x54f/0xce0 fs/ext4/namei.c:3081
vfs_mkdir+0x398/0x570 fs/namei.c:4105
do_mkdirat+0x1eb/0x450 fs/namei.c:4130
__do_sys_mkdirat fs/namei.c:4145 [inline]
__se_sys_mkdirat fs/namei.c:4143 [inline]
__x64_sys_mkdirat+0x89/0xa0 fs/namei.c:4143
x64_sys_call+0x6c6/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:259
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:0x7f8e8649a819
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 61 17 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:00007ffe77255668 EFLAGS: 00000246 ORIG_RAX: 0000000000000102
RAX: ffffffffffffffda RBX: 0030656c69662f2e RCX: 00007f8e8649a819
RDX: 0000000000000000 RSI: 00000000200005c0 RDI: 00000000ffffff9c
RBP: 000000000000012b R08: 0000555500393932 R09: 0000555500393932
R10: 0000555500393932 R11: 0000000000000246 R12: 00007ffe77255770
R13: 00007ffe77255938 R14: 0000000000000001 R15: 0000000000000001
</TASK>

The buggy address belongs to the physical page:
page:ffffea000454b700 refcount:3 mapcount:0 mapping:ffff88810054f650 index:0x3f pfn:0x1152dc
memcg:ffff888100334000
aops:def_blk_aops ino:700000
flags: 0x420000000000204a(referenced|dirty|workingset|private|zone=1)
raw: 420000000000204a 0000000000000000 dead000000000122 ffff88810054f650
raw: 000000000000003f ffff888123d6a498 00000003ffffffff ffff888100334000
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 298, tgid 298 (syz-executor167), ts 24597397389, free_ts 18917580587
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_mkdir+0x54f/0xce0 fs/ext4/namei.c:3081
vfs_mkdir+0x398/0x570 fs/namei.c:4105
do_mkdirat+0x1eb/0x450 fs/namei.c:4130
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
exit_mmap+0x460/0xbe0 mm/mmap.c:3348
__mmput+0x95/0x310 kernel/fork.c:1298
mmput+0x56/0x170 kernel/fork.c:1321
exit_mm kernel/exit.c:568 [inline]
do_exit+0xb29/0x2b80 kernel/exit.c:864
do_group_exit+0x21a/0x2d0 kernel/exit.c:1027
__do_sys_exit_group kernel/exit.c:1038 [inline]
__se_sys_exit_group kernel/exit.c:1036 [inline]
__x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1036
x64_sys_call+0x610/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:232
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:
ffff8881152dcf00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff8881152dcf80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8881152dd000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Jun 24, 2025, 1:25:04 PM6/24/25
to syzkaller-a...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit 35d0aa6db9d93307085871ceab8a729594a98162
Author: Artem Sadovnikov <a.sado...@ispras.ru>
Date: Fri Apr 4 08:28:05 2025 +0000

ext4: fix off-by-one error in do_split

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=140f6b70580000
start commit: 3c6d0251e1fb ANDROID: ABI: Update pixel symbol list
git tree: android14-6.1
kernel config: https://syzkaller.appspot.com/x/.config?x=45ede6eadcea8100
dashboard link: https://syzkaller.appspot.com/bug?extid=c3bf43af1bfb618be15b
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1783a170580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=155c9ad4580000

If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: ext4: fix off-by-one error in do_split

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

Aleksandr Nogikh

unread,
Jun 24, 2025, 1:26:13 PM6/24/25
to syzbot, syzkaller-a...@googlegroups.com
#syz fix: ext4: fix off-by-one error in do_split

> --
> You received this message because you are subscribed to the Google Groups "syzkaller-android-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-android...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/syzkaller-android-bugs/685adf6e.a00a0220.34b642.0074.GAE%40google.com.
Reply all
Reply to author
Forward
0 new messages