[v5.15] KASAN: use-after-free Write in ext4_insert_dentry

2 views
Skip to first unread message

syzbot

unread,
Nov 30, 2024, 12:09:24 AM11/30/24
Hello,

syzbot found the following issue on:

HEAD commit: 0a51d2d4527b Linux 5.15.173
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=12172d30580000
kernel config: https://syzkaller.appspot.com/x/.config?x=48dad5136d11d5fc
dashboard link: https://syzkaller.appspot.com/bug?extid=0472540567477a66423c
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/df502ed32946/disk-0a51d2d4.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/a6f49f24ceaa/vmlinux-0a51d2d4.xz
kernel image: https://storage.googleapis.com/syzbot-assets/f45db4b68abf/bzImage-0a51d2d4.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

EXT4-fs (loop0): 1 orphan inode deleted
EXT4-fs (loop0): mounted filesystem without journal. Opts: ,errors=continue. Quota mode: none.
==================================================================
BUG: KASAN: use-after-free in ext4_insert_dentry+0x366/0x6c0 fs/ext4/namei.c:2155
Write of size 250 at addr ffff88805c1f3f18 by task syz.0.89/4834

CPU: 0 PID: 4834 Comm: syz.0.89 Not tainted 5.15.173-syzkaller #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+0x1e3/0x2d0 lib/dump_stack.c:106
print_address_description+0x63/0x3b0 mm/kasan/report.c:248
__kasan_report mm/kasan/report.c:434 [inline]
kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
kasan_check_range+0x27e/0x290 mm/kasan/generic.c:189
memcpy+0x3c/0x60 mm/kasan/shadow.c:66
ext4_insert_dentry+0x366/0x6c0 fs/ext4/namei.c:2155
add_dirent_to_buf+0x384/0x7d0 fs/ext4/namei.c:2200
make_indexed_dir+0xf34/0x15a0 fs/ext4/namei.c:2398
ext4_add_entry+0xde2/0x12b0 fs/ext4/namei.c:2504
ext4_mkdir+0x54f/0xce0 fs/ext4/namei.c:3081
vfs_mkdir+0x3b6/0x590 fs/namei.c:4065
do_mkdirat+0x260/0x520 fs/namei.c:4090
__do_sys_mkdirat fs/namei.c:4105 [inline]
__se_sys_mkdirat fs/namei.c:4103 [inline]
__x64_sys_mkdirat+0x85/0x90 fs/namei.c:4103
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:0x7f8c9ef44809
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f8c9cdba058 EFLAGS: 00000246 ORIG_RAX: 0000000000000102
RAX: ffffffffffffffda RBX: 00007f8c9f109fa0 RCX: 00007f8c9ef44809
RDX: 5be60480b9579340 RSI: 0000000020000940 RDI: ffffffffffffff9c
RBP: 00007f8c9efb793e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f8c9f109fa0 R15: 00007ffe6a594078
</TASK>

The buggy address belongs to the page:
page:ffffea0001707cc0 refcount:3 mapcount:0 mapping:ffff88801dd65af0 index:0x3f pfn:0x5c1f3
memcg:ffff888079f0c000
aops:def_blk_aops ino:700000
flags: 0xfff0000000202a(referenced|dirty|active|private|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff0000000202a 0000000000000000 dead000000000122 ffff88801dd65af0
raw: 000000000000003f ffff88806026dbc8 00000003ffffffff ffff888079f0c000
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 4834, ts 96920942868, free_ts 96852615762
prep_new_page mm/page_alloc.c:2426 [inline]
get_page_from_freelist+0x3b78/0x3d40 mm/page_alloc.c:4192
__alloc_pages+0x272/0x700 mm/page_alloc.c:5464
__page_cache_alloc+0xd4/0x4a0 mm/filemap.c:1022
pagecache_get_page+0xa91/0x1010 mm/filemap.c:1940
find_or_create_page include/linux/pagemap.h:420 [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+0x22a/0xaf0 fs/buffer.c:1336
sb_getblk include/linux/buffer_head.h:361 [inline]
ext4_getblk+0x259/0x710 fs/ext4/inode.c:876
ext4_bread+0x2a/0x170 fs/ext4/inode.c:922
ext4_append+0x31f/0x5c0 fs/ext4/namei.c:83
make_indexed_dir+0x515/0x15a0 fs/ext4/namei.c:2318
ext4_add_entry+0xde2/0x12b0 fs/ext4/namei.c:2504
ext4_mkdir+0x54f/0xce0 fs/ext4/namei.c:3081
vfs_mkdir+0x3b6/0x590 fs/namei.c:4065
do_mkdirat+0x260/0x520 fs/namei.c:4090
__do_sys_mkdirat fs/namei.c:4105 [inline]
__se_sys_mkdirat fs/namei.c:4103 [inline]
__x64_sys_mkdirat+0x85/0x90 fs/namei.c:4103
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
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1340 [inline]
free_pcp_prepare mm/page_alloc.c:1391 [inline]
free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
free_unref_page_list+0x1f7/0x8e0 mm/page_alloc.c:3433
release_pages+0x1bb9/0x1f40 mm/swap.c:963
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:2668
__do_munmap+0x12db/0x1740 mm/mmap.c:2899
__vm_munmap+0x134/0x230 mm/mmap.c:2922
__do_sys_munmap mm/mmap.c:2948 [inline]
__se_sys_munmap mm/mmap.c:2944 [inline]
__x64_sys_munmap+0x67/0x70 mm/mmap.c:2944
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:
ffff88805c1f3f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88805c1f3f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88805c1f4000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff88805c1f4080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88805c1f4100: 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 [email protected].

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 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,
Nov 30, 2024, 1:16:27 AM11/30/24
syzbot has found a reproducer for the following issue on:

HEAD commit: 0a51d2d4527b Linux 5.15.173
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=106919e8580000
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1588ad30580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16036f78580000
mounted in repro: https://storage.googleapis.com/syzbot-assets/157305331a31/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

EXT4-fs error (device loop0): ext4_xattr_inode_iget:409: comm syz-executor598: error while reading EA inode 1 err=-117
EXT4-fs (loop0): 1 orphan inode deleted
EXT4-fs (loop0): mounted filesystem without journal. Opts: ,errors=continue. Quota mode: none.
==================================================================
BUG: KASAN: use-after-free in ext4_insert_dentry+0x366/0x6c0 fs/ext4/namei.c:2155
Write of size 250 at addr ffff88806f7d9f18 by task syz-executor598/4162

CPU: 1 PID: 4162 Comm: syz-executor598 Not tainted 5.15.173-syzkaller #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+0x1e3/0x2d0 lib/dump_stack.c:106
print_address_description+0x63/0x3b0 mm/kasan/report.c:248
__kasan_report mm/kasan/report.c:434 [inline]
kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
kasan_check_range+0x27e/0x290 mm/kasan/generic.c:189
memcpy+0x3c/0x60 mm/kasan/shadow.c:66
ext4_insert_dentry+0x366/0x6c0 fs/ext4/namei.c:2155
add_dirent_to_buf+0x384/0x7d0 fs/ext4/namei.c:2200
make_indexed_dir+0xf34/0x15a0 fs/ext4/namei.c:2398
ext4_add_entry+0xde2/0x12b0 fs/ext4/namei.c:2504
ext4_mkdir+0x54f/0xce0 fs/ext4/namei.c:3081
vfs_mkdir+0x3b6/0x590 fs/namei.c:4065
do_mkdirat+0x260/0x520 fs/namei.c:4090
__do_sys_mkdirat fs/namei.c:4105 [inline]
__se_sys_mkdirat fs/namei.c:4103 [inline]
__x64_sys_mkdirat+0x85/0x90 fs/namei.c:4103
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:0x7f97ab04df69
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 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:00007ffc31551f88 EFLAGS: 00000246 ORIG_RAX: 0000000000000102
RAX: ffffffffffffffda RBX: 00007ffc315520a0 RCX: 00007f97ab04df69
RDX: 5be60480b9579340 RSI: 0000000020000940 RDI: 00000000ffffff9c
RBP: 00007ffc315520a8 R08: 00007f97ab091250 R09: 00007f97ab091250
R10: 00007f97ab091250 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f97ab0c26a0 R15: 000000000000001c
</TASK>

The buggy address belongs to the page:
page:ffffea0001bdf640 refcount:3 mapcount:0 mapping:ffff88801d9d4f30 index:0x3f pfn:0x6f7d9
memcg:ffff888140774000
aops:def_blk_aops ino:700000
flags: 0xfff0000000202a(referenced|dirty|active|private|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff0000000202a 0000000000000000 dead000000000122 ffff88801d9d4f30
raw: 000000000000003f ffff8880727efae0 00000003ffffffff ffff888140774000
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 4162, ts 50450137623, free_ts 44746523910
exit_mmap+0x3cd/0x670 mm/mmap.c:3188
__mmput+0x112/0x3b0 kernel/fork.c:1127
exit_mm+0x688/0x7f0 kernel/exit.c:550
do_exit+0x626/0x2480 kernel/exit.c:861
do_group_exit+0x144/0x310 kernel/exit.c:996
__do_sys_exit_group kernel/exit.c:1007 [inline]
__se_sys_exit_group kernel/exit.c:1005 [inline]
__x64_sys_exit_group+0x3b/0x40 kernel/exit.c:1005
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:
ffff88806f7d9f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88806f7d9f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88806f7da000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff88806f7da080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88806f7da100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================


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