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

14 views
Skip to first unread message

syzbot

unread,
Oct 26, 2024, 8:37:27 PM10/26/24
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 5e4635681cf1 Revert "perf/aux: Fix AUX buffer serialization"
git tree: android13-5.15-lts
console+strace: https://syzkaller.appspot.com/x/log.txt?x=15d3365f980000
kernel config: https://syzkaller.appspot.com/x/.config?x=99b2b6b0ab6b5a74
dashboard link: https://syzkaller.appspot.com/bug?extid=4f97858f927585131c64
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=13a4c4a7980000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13d3365f980000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/0ba0258eac83/disk-5e463568.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/b8ef199aeb8c/vmlinux-5e463568.xz
kernel image: https://storage.googleapis.com/syzbot-assets/19c71ee4b50d/bzImage-5e463568.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/6a5f8e6207fd/mount_0.gz

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

EXT4-fs error (device loop0): ext4_orphan_get:1402: comm syz-executor413: couldn't read orphan inode 15 (err -117)
EXT4-fs (loop0): mounted filesystem without journal. Opts: ,errors=continue. Quota mode: none.
==================================================================
BUG: KASAN: use-after-free in ext4_insert_dentry+0x392/0x710 fs/ext4/namei.c:2153
Write of size 251 at addr ffff88811c5c0f14 by task syz-executor413/297

CPU: 0 PID: 297 Comm: syz-executor413 Not tainted 5.15.167-syzkaller-android13-5.15.167_r00 #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/0x1c0 lib/dump_stack.c:106
print_address_description+0x87/0x3b0 mm/kasan/report.c:248
__kasan_report mm/kasan/report.c:427 [inline]
kasan_report+0x179/0x1c0 mm/kasan/report.c:444
kasan_check_range+0x293/0x2a0 mm/kasan/generic.c:189
memcpy+0x44/0x70 mm/kasan/shadow.c:66
ext4_insert_dentry+0x392/0x710 fs/ext4/namei.c:2153
add_dirent_to_buf+0x384/0x7d0 fs/ext4/namei.c:2198
make_indexed_dir+0xf34/0x15a0 fs/ext4/namei.c:2396
ext4_add_entry+0xde2/0x12b0 fs/ext4/namei.c:2502
ext4_add_nondir+0x97/0x290 fs/ext4/namei.c:2843
ext4_symlink+0x913/0xed0 fs/ext4/namei.c:3496
vfs_symlink+0x29f/0x480 fs/namei.c:4429
do_symlinkat+0x1ea/0x5a0 fs/namei.c:4458
__do_sys_symlink fs/namei.c:4480 [inline]
__se_sys_symlink fs/namei.c:4478 [inline]
__x64_sys_symlink+0x7e/0x90 fs/namei.c:4478
x64_sys_call+0x290/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:89
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f25dc209519
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 1c 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:00007ffda46d5138 EFLAGS: 00000246 ORIG_RAX: 0000000000000058
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f25dc209519
RDX: 0000000000000000 RSI: 0000000020000cc0 RDI: 0000000020000dc0
RBP: 00007f25dc24d590 R08: 00007f25dc24d5b2 R09: 00007f25dc24d5b2
R10: 00007f25dc24d5b2 R11: 0000000000000246 R12: 00007f25dc24d515
R13: 00007ffda46d51a0 R14: 0000000000000003 R15: 00007ffda46d5178
</TASK>

The buggy address belongs to the page:
page:ffffea0004717000 refcount:3 mapcount:0 mapping:ffff88810928b458 index:0x3f pfn:0x11c5c0
memcg:ffff888100214000
aops:def_blk_aops ino:700000
flags: 0x400000000000202a(referenced|dirty|active|private|zone=1)
raw: 400000000000202a 0000000000000000 dead000000000122 ffff88810928b458
raw: 000000000000003f ffff88810981e5e8 00000003ffffffff ffff888100214000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Movable, gfp_mask 0x108c48(GFP_NOFS|__GFP_NOFAIL|__GFP_HARDWALL|__GFP_MOVABLE), pid 297, ts 24731691395, free_ts 18321272025
set_page_owner include/linux/page_owner.h:33 [inline]
post_alloc_hook+0x1a3/0x1b0 mm/page_alloc.c:2605
prep_new_page+0x1b/0x110 mm/page_alloc.c:2611
get_page_from_freelist+0x3550/0x35d0 mm/page_alloc.c:4485
__alloc_pages+0x27e/0x8f0 mm/page_alloc.c:5779
__alloc_pages_node include/linux/gfp.h:591 [inline]
alloc_pages_node include/linux/gfp.h:605 [inline]
alloc_pages include/linux/gfp.h:618 [inline]
__page_cache_alloc include/linux/pagemap.h:305 [inline]
pagecache_get_page+0xb18/0xeb0 mm/filemap.c:1946
find_or_create_page include/linux/pagemap.h:418 [inline]
grow_dev_page fs/buffer.c:949 [inline]
grow_buffers fs/buffer.c:1014 [inline]
__getblk_slow fs/buffer.c:1041 [inline]
__getblk_gfp+0x21e/0x7c0 fs/buffer.c:1336
sb_getblk include/linux/buffer_head.h:361 [inline]
ext4_getblk+0x259/0x700 fs/ext4/inode.c:877
ext4_bread+0x2f/0x180 fs/ext4/inode.c:923
ext4_append+0x31f/0x5b0 fs/ext4/namei.c:83
make_indexed_dir+0x515/0x15a0 fs/ext4/namei.c:2316
ext4_add_entry+0xde2/0x12b0 fs/ext4/namei.c:2502
ext4_add_nondir+0x97/0x290 fs/ext4/namei.c:2843
ext4_symlink+0x913/0xed0 fs/ext4/namei.c:3496
vfs_symlink+0x29f/0x480 fs/namei.c:4429
do_symlinkat+0x1ea/0x5a0 fs/namei.c:4458
__do_sys_symlink fs/namei.c:4480 [inline]
__se_sys_symlink fs/namei.c:4478 [inline]
__x64_sys_symlink+0x7e/0x90 fs/namei.c:4478
page last free stack trace:
reset_page_owner include/linux/page_owner.h:26 [inline]
free_pages_prepare mm/page_alloc.c:1472 [inline]
free_pcp_prepare mm/page_alloc.c:1544 [inline]
free_unref_page_prepare+0x7c8/0x7d0 mm/page_alloc.c:3534
free_unref_page_list+0x14b/0xa60 mm/page_alloc.c:3671
release_pages+0x1310/0x1370 mm/swap.c:1009
free_pages_and_swap_cache+0x8a/0xa0 mm/swap_state.c:320
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:2691
__do_munmap+0x1421/0x1a90 mm/mmap.c:2925
__vm_munmap+0x166/0x2a0 mm/mmap.c:2948
__do_sys_munmap mm/mmap.c:2974 [inline]
__se_sys_munmap mm/mmap.c:2970 [inline]
__x64_sys_munmap+0x6b/0x80 mm/mmap.c:2970
x64_sys_call+0x75/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:12
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

Memory state around the buggy address:
ffff88811c5c0f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88811c5c0f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88811c5c1000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff88811c5c1080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88811c5c1100: 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 2, 2025, 6:46:04 AMJun 2
to syzkaller-a...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit 2883e9e74f73f9265e5f8d1aaaa89034b308e433
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=12c9f00c580000
start commit: b4bd207b0380 Merge branch 'android13-5.15' into android13-..
git tree: android13-5.15-lts
kernel config: https://syzkaller.appspot.com/x/.config?x=f0e2420ad44d4165
dashboard link: https://syzkaller.appspot.com/bug?extid=4f97858f927585131c64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11c63730580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1293af44580000

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
Reply all
Reply to author
Forward
0 new messages