[Android 6.1] KASAN: use-after-free Read in ext4_htree_fill_tree

12 views
Skip to first unread message

syzbot

unread,
Dec 22, 2024, 2:07:25 PM12/22/24
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 3e3f2b9e9fca BACKPORT: f2fs: fix to account dirty data in ..
git tree: android14-6.1
console+strace: https://syzkaller.appspot.com/x/log.txt?x=14cc0adf980000
kernel config: https://syzkaller.appspot.com/x/.config?x=8f475bced78b11d3
dashboard link: https://syzkaller.appspot.com/bug?extid=e1370dc6128e4079c651
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=11e398c4580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=108d7cf8580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/47e832a1c910/disk-3e3f2b9e.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/1cfb614b7994/vmlinux-3e3f2b9e.xz
kernel image: https://storage.googleapis.com/syzbot-assets/5e23c7ad3c44/bzImage-3e3f2b9e.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/7ece018a50cf/mount_0.gz

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

==================================================================
BUG: KASAN: use-after-free in ext4_htree_fill_tree+0x1316/0x13e0 fs/ext4/namei.c:1246
Read of size 1 at addr ffff888120dc3a67 by task syz-executor274/298

CPU: 0 PID: 298 Comm: syz-executor274 Not tainted 6.1.118-syzkaller-00074-g3e3f2b9e9fca #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
__asan_report_load1_noabort+0x14/0x20 mm/kasan/report_generic.c:348
ext4_htree_fill_tree+0x1316/0x13e0 fs/ext4/namei.c:1246
ext4_dx_readdir fs/ext4/dir.c:605 [inline]
ext4_readdir+0x2e6f/0x3860 fs/ext4/dir.c:142
iterate_dir+0x265/0x600
__do_sys_getdents64 fs/readdir.c:369 [inline]
__se_sys_getdents64+0x1c1/0x460 fs/readdir.c:354
__x64_sys_getdents64+0x7b/0x90 fs/readdir.c:354
x64_sys_call+0x5ae/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:218
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:0x7f856d732a53
Code: c1 66 0f 1f 44 00 00 48 83 c4 08 48 89 ef 5b 5d e9 e2 12 fb ff 66 90 b8 ff ff ff 7f 48 39 c2 48 0f 47 d0 b8 d9 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 05 c3 0f 1f 40 00 48 c7 c2 b8 ff ff ff f7 d8
RSP: 002b:00007fff362977e8 EFLAGS: 00000293 ORIG_RAX: 00000000000000d9
RAX: ffffffffffffffda RBX: 0000555586650830 RCX: 00007f856d732a53
RDX: 0000000000008000 RSI: 0000555586650830 RDI: 0000000000000004
RBP: 0000555586650804 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000001000 R11: 0000000000000293 R12: ffffffffffffffb8
R13: 0000000000000010 R14: 0000555586650800 R15: 431bde82d7b634db
</TASK>

The buggy address belongs to the physical page:
page:ffffea00048370c0 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x120dc3
flags: 0x4000000000000000(zone=1)
raw: 4000000000000000 dead000000000100 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x500cc2(GFP_HIGHUSER|__GFP_ACCOUNT), pid 227, tgid 227 (sshd), ts 14246216928, free_ts 14246318487
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+0x2f41/0x2fc0 mm/page_alloc.c:4462
__alloc_pages+0x234/0x610 mm/page_alloc.c:5759
__alloc_pages_node include/linux/gfp.h:236 [inline]
alloc_pages_node include/linux/gfp.h:259 [inline]
alloc_pages include/linux/gfp.h:270 [inline]
pipe_write+0x56a/0x1990 fs/pipe.c:501
call_write_iter include/linux/fs.h:2274 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0xaf6/0xed0 fs/read_write.c:584
ksys_write+0x199/0x2c0 fs/read_write.c:637
__do_sys_write fs/read_write.c:649 [inline]
__se_sys_write fs/read_write.c:646 [inline]
__x64_sys_write+0x7b/0x90 fs/read_write.c:646
x64_sys_call+0x2f/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:2
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
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+0xb2/0x5c0 mm/page_alloc.c:3607
__folio_put_small mm/swap.c:105 [inline]
__folio_put+0xaa/0xe0 mm/swap.c:128
folio_put include/linux/mm.h:1431 [inline]
put_page include/linux/mm.h:1483 [inline]
anon_pipe_buf_release+0x187/0x200 fs/pipe.c:138
pipe_buf_release include/linux/pipe_fs_i.h:199 [inline]
pipe_read+0x5a6/0x1040 fs/pipe.c:324
call_read_iter include/linux/fs.h:2268 [inline]
new_sync_read fs/read_write.c:389 [inline]
vfs_read+0x801/0xae0 fs/read_write.c:470
ksys_read+0x199/0x2c0 fs/read_write.c:613
__do_sys_read fs/read_write.c:623 [inline]
__se_sys_read fs/read_write.c:621 [inline]
__x64_sys_read+0x7b/0x90 fs/read_write.c:621
x64_sys_call+0x28/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:1
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:
ffff888120dc3900: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff888120dc3980: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888120dc3a00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff888120dc3a80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff888120dc3b00: 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,
Dec 27, 2024, 2:48:22 PM12/27/24
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: b4bd207b0380 Merge branch 'android13-5.15' into android13-..
git tree: android13-5.15-lts
console+strace: https://syzkaller.appspot.com/x/log.txt?x=159e10b0580000
kernel config: https://syzkaller.appspot.com/x/.config?x=f0e2420ad44d4165
dashboard link: https://syzkaller.appspot.com/bug?extid=254e41833ea7ee21fe91
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=129ad2f8580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=139e10b0580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/d151ccdddf0d/disk-b4bd207b.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/bbad9e4fe0f4/vmlinux-b4bd207b.xz
kernel image: https://storage.googleapis.com/syzbot-assets/299545204748/bzImage-b4bd207b.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/a46080a50cc8/mount_0.gz

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

BUG: KASAN: use-after-free in ext4_htree_fill_tree+0x131b/0x13e0 fs/ext4/namei.c:1246
Read of size 1 at addr ffff888106bc2a67 by task syz-executor263/306

CPU: 0 PID: 306 Comm: syz-executor263 Not tainted 5.15.173-syzkaller-00161-gb4bd207b0380 #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
__asan_report_load1_noabort+0x14/0x20 mm/kasan/report_generic.c:306
ext4_htree_fill_tree+0x131b/0x13e0 fs/ext4/namei.c:1246
ext4_dx_readdir fs/ext4/dir.c:606 [inline]
ext4_readdir+0x2f75/0x3960 fs/ext4/dir.c:142
iterate_dir+0x265/0x600
__do_sys_getdents64 fs/readdir.c:369 [inline]
__se_sys_getdents64+0x1c1/0x460 fs/readdir.c:354
__x64_sys_getdents64+0x7b/0x90 fs/readdir.c:354
x64_sys_call+0x5ae/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:218
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:0x7f38484ab1a3
Code: c1 66 0f 1f 44 00 00 48 83 c4 08 48 89 ef 5b 5d e9 c2 2b fb ff 66 90 b8 ff ff ff 7f 48 39 c2 48 0f 47 d0 b8 d9 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 05 c3 0f 1f 40 00 48 c7 c2 b8 ff ff ff f7 d8
RSP: 002b:00007ffc967c2478 EFLAGS: 00000293 ORIG_RAX: 00000000000000d9
RAX: ffffffffffffffda RBX: 000055557e368730 RCX: 00007f38484ab1a3
RDX: 0000000000008000 RSI: 000055557e368730 RDI: 0000000000000004
RBP: 000055557e368704 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000001000 R11: 0000000000000293 R12: ffffffffffffffb8
R13: 0000000000000010 R14: 000055557e368700 R15: 431bde82d7b634db
</TASK>

The buggy address belongs to the page:
page:ffffea00041af080 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x106bc2
flags: 0x4000000000000000(zone=1)
raw: 4000000000000000 0000000000000000 dead000000000000 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, ts 1258571303, free_ts 14556922226
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
allocate_slab mm/slub.c:1932 [inline]
new_slab+0x9a/0x4e0 mm/slub.c:1995
___slab_alloc+0x39e/0x830 mm/slub.c:3028
__slab_alloc+0x4a/0x90 mm/slub.c:3115
slab_alloc_node mm/slub.c:3206 [inline]
slab_alloc mm/slub.c:3250 [inline]
kmem_cache_alloc_trace+0x147/0x270 mm/slub.c:3267
kmalloc include/linux/slab.h:603 [inline]
kzalloc include/linux/slab.h:733 [inline]
kobject_uevent_env+0x269/0x700 lib/kobject_uevent.c:539
kobject_uevent+0x1f/0x30 lib/kobject_uevent.c:657
kernel_add_sysfs_param+0x108/0x130 kernel/params.c:816
param_sysfs_builtin+0x16a/0x1f0 kernel/params.c:851
param_sysfs_init+0x6a/0x70 kernel/params.c:970
do_one_initcall+0x182/0x610 init/main.c:1302
do_initcall_level+0x186/0x310 init/main.c:1375
do_initcalls+0x4e/0x90 init/main.c:1391
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+0xe8/0x750 mm/page_alloc.c:3616
free_the_page mm/page_alloc.c:805 [inline]
__free_pages+0x61/0xf0 mm/page_alloc.c:5855
__free_slab+0xec/0x1d0 mm/slub.c:2020
free_slab mm/slub.c:2035 [inline]
discard_slab mm/slub.c:2041 [inline]
__unfreeze_partials+0x165/0x1a0 mm/slub.c:2527
put_cpu_partial+0xc4/0x120 mm/slub.c:2607
__slab_free+0x1c8/0x290 mm/slub.c:3390
do_slab_free mm/slub.c:3509 [inline]
___cache_free+0x109/0x120 mm/slub.c:3530
qlink_free+0x4d/0x90 mm/kasan/quarantine.c:157
qlist_free_all+0x44/0xb0 mm/kasan/quarantine.c:176
kasan_quarantine_reduce+0x15a/0x180 mm/kasan/quarantine.c:283
__kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:443
kasan_slab_alloc include/linux/kasan.h:217 [inline]
slab_post_alloc_hook+0x53/0x2c0 mm/slab.h:550
slab_alloc_node mm/slub.c:3240 [inline]
slab_alloc mm/slub.c:3250 [inline]
kmem_cache_alloc+0xf5/0x250 mm/slub.c:3255
sock_alloc_inode+0x1b/0xb0 net/socket.c:303
alloc_inode fs/inode.c:236 [inline]
new_inode_pseudo+0x64/0x220 fs/inode.c:976

Memory state around the buggy address:
ffff888106bc2900: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff888106bc2980: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888106bc2a00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff888106bc2a80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff888106bc2b00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
Reply all
Reply to author
Forward
0 new messages