[Android 5.10] KASAN: use-after-free Read in ext4_inlinedir_to_tree

0 views
Skip to first unread message

syzbot

unread,
Apr 13, 2024, 11:44:32 PMApr 13
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 4e1bc8d8e8ae Merge branch 'android13-5.10' into branch 'an..
git tree: android13-5.10-lts
console+strace: https://syzkaller.appspot.com/x/log.txt?x=140bc6f5180000
kernel config: https://syzkaller.appspot.com/x/.config?x=1a6e39f6bdc97aed
dashboard link: https://syzkaller.appspot.com/bug?extid=52813a2561e5222492ee
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=132f1b6d180000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16e1376d180000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/cce4facb9f9d/disk-4e1bc8d8.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/b73ea3cf695a/vmlinux-4e1bc8d8.xz
kernel image: https://storage.googleapis.com/syzbot-assets/8d25aa75f46d/bzImage-4e1bc8d8.xz
mounted in repro #1: https://storage.googleapis.com/syzbot-assets/f748cdb2b28c/mount_0.gz
mounted in repro #2: https://storage.googleapis.com/syzbot-assets/b6b314a87df6/mount_7.gz

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

==================================================================
BUG: KASAN: use-after-free in ext4_read_inline_data fs/ext4/inline.c:209 [inline]
BUG: KASAN: use-after-free in ext4_inlinedir_to_tree+0x555/0x1160 fs/ext4/inline.c:1401
Read of size 68 at addr ffff888107788ec9 by task syz-executor210/286

CPU: 0 PID: 286 Comm: syz-executor210 Not tainted 5.10.209-syzkaller-00002-g4e1bc8d8e8ae #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
print_address_description+0x81/0x3b0 mm/kasan/report.c:248
__kasan_report mm/kasan/report.c:435 [inline]
kasan_report+0x179/0x1c0 mm/kasan/report.c:452
kasan_check_range+0x293/0x2a0 mm/kasan/generic.c:189
memcpy+0x2d/0x70 mm/kasan/shadow.c:65
ext4_read_inline_data fs/ext4/inline.c:209 [inline]
ext4_inlinedir_to_tree+0x555/0x1160 fs/ext4/inline.c:1401
ext4_htree_fill_tree+0x5d1/0x13e0 fs/ext4/namei.c:1185
ext4_dx_readdir fs/ext4/dir.c:598 [inline]
ext4_readdir+0x2dde/0x37c0 fs/ext4/dir.c:142
iterate_dir+0x265/0x580
__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
do_syscall_64+0x34/0x70
entry_SYSCALL_64_after_hwframe+0x61/0xc6
RIP: 0033:0x7f69230e1063
Code: c1 66 0f 1f 44 00 00 48 83 c4 08 48 89 ef 5b 5d e9 32 38 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:00007ffc1dccfea8 EFLAGS: 00000293 ORIG_RAX: 00000000000000d9
RAX: ffffffffffffffda RBX: 0000555555d57770 RCX: 00007f69230e1063
RDX: 0000000000008000 RSI: 0000555555d57770 RDI: 0000000000000005
RBP: 0000555555d57744 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000001000 R11: 0000000000000293 R12: ffffffffffffffb8
R13: 0000000000000016 R14: 0000555555d57740 R15: 00007ffc1dcd3210

Allocated by task 1:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track mm/kasan/common.c:45 [inline]
set_alloc_info mm/kasan/common.c:430 [inline]
____kasan_kmalloc+0xdb/0x110 mm/kasan/common.c:509
__kasan_kmalloc+0x9/0x10 mm/kasan/common.c:518
kasan_kmalloc include/linux/kasan.h:254 [inline]
__kmalloc+0x1aa/0x330 mm/slub.c:4033
kmalloc include/linux/slab.h:557 [inline]
kzalloc include/linux/slab.h:664 [inline]
kobject_get_path+0xbc/0x1f0 lib/kobject.c:184
kobject_uevent_env+0x27f/0x700 lib/kobject_uevent.c:529
kobject_uevent+0x1f/0x30 lib/kobject_uevent.c:642
kernel_add_sysfs_param+0x108/0x12d kernel/params.c:798
param_sysfs_builtin+0x16a/0x1e2 kernel/params.c:833
param_sysfs_init+0x6a/0x6f kernel/params.c:954
do_one_initcall+0x189/0x620 init/main.c:1195
do_initcall_level+0x186/0x304 init/main.c:1268
do_initcalls+0x4e/0x8e init/main.c:1284
do_basic_setup+0x88/0x91 init/main.c:1304
kernel_init_freeable+0x2be/0x3f5 init/main.c:1508
kernel_init+0x11/0x280 init/main.c:1395
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:299

The buggy address belongs to the object at ffff888107788ec0
which belongs to the cache kmalloc-16 of size 16
The buggy address is located 9 bytes inside of
16-byte region [ffff888107788ec0, ffff888107788ed0)
The buggy address belongs to the page:
page:ffffea00041de200 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888107788b00 pfn:0x107788
flags: 0x4000000000000200(slab)
raw: 4000000000000200 0000000000000000 0000000100000001 ffff888100043b00
raw: ffff888107788b00 000000008080002d 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 1, ts 1023983998, free_ts 0
set_page_owner include/linux/page_owner.h:35 [inline]
post_alloc_hook mm/page_alloc.c:2456 [inline]
prep_new_page+0x166/0x180 mm/page_alloc.c:2462
get_page_from_freelist+0x2d8c/0x2f30 mm/page_alloc.c:4254
__alloc_pages_nodemask+0x435/0xaf0 mm/page_alloc.c:5346
allocate_slab mm/slub.c:1808 [inline]
new_slab+0x80/0x400 mm/slub.c:1869
new_slab_objects mm/slub.c:2627 [inline]
___slab_alloc+0x302/0x4b0 mm/slub.c:2791
__slab_alloc+0x63/0xa0 mm/slub.c:2831
slab_alloc_node mm/slub.c:2913 [inline]
slab_alloc mm/slub.c:2955 [inline]
__kmalloc+0x204/0x330 mm/slub.c:4029
kmalloc include/linux/slab.h:557 [inline]
kzalloc include/linux/slab.h:664 [inline]
kobject_get_path+0xbc/0x1f0 lib/kobject.c:184
kobject_uevent_env+0x27f/0x700 lib/kobject_uevent.c:529
kobject_uevent+0x1f/0x30 lib/kobject_uevent.c:642
kernel_add_sysfs_param+0x108/0x12d kernel/params.c:798
param_sysfs_builtin+0x16a/0x1e2 kernel/params.c:833
param_sysfs_init+0x6a/0x6f kernel/params.c:954
do_one_initcall+0x189/0x620 init/main.c:1195
do_initcall_level+0x186/0x304 init/main.c:1268
do_initcalls+0x4e/0x8e init/main.c:1284
page_owner free stack trace missing

Memory state around the buggy address:
ffff888107788d80: fb fb fc fc fb fb fc fc 00 00 fc fc 00 00 fc fc
ffff888107788e00: fb fb fc fc fb fb fc fc fb fb fc fc 00 00 fc fc
>ffff888107788e80: fb fb fc fc fb fb fc fc fb fb fc fc fb fb fc fc
^
ffff888107788f00: fb fb fc fc 00 00 fc fc 00 00 fc fc 00 00 fc fc
ffff888107788f80: fb fb fc fc fb fb fc fc fb fb fc fc 00 00 fc fc
==================================================================
EXT4-fs error (device loop1): ext4_inlinedir_to_tree:1439: inode #12: block 7: comm syz-executor210: path /root/syzkaller.a4CAkU/0/file0/file0: bad entry in directory: directory entry overrun - offset=34816, inode=2538880996, rec_len=34812, size=128 fake=0
EXT4-fs error (device loop1): empty_inline_dir:1835: inode #12: block 7: comm syz-executor210: bad entry in directory: directory entry overrun - offset=4, inode=2538880996, rec_len=34812, size=60 fake=0
EXT4-fs warning (device loop1): empty_inline_dir:1842: bad inline directory (dir #12) - inode 2538880996, rec_len 34812, name_len 234inline size 60
EXT4-fs error (device loop1): ext4_inlinedir_to_tree:1439: inode #12: block 7: comm syz-executor210: path /root/syzkaller.a4CAkU/0/file0/file0: bad entry in directory: directory entry overrun - offset=34816, inode=2538880996, rec_len=34812, size=128 fake=0
EXT4-fs error (device loop1): empty_inline_dir:1835: inode #12: block 7: comm syz-executor210: bad entry in directory: directory entry overrun - offset=4, inode=2538880996, rec_len=34812, size=60 fake=0
EXT4-fs warning (device loop1): empty_inline_dir:1842: bad inline directory (dir #12) - inode 2538880996, rec_len 34812, name_len 234inline size 60
EXT4-fs error (device loop1): ext4_inlinedir_to_tree:1439: inode #12: block 7: comm syz-executor210: path /root/syzkaller.a4CAkU/0/file0/file0: bad entry in directory: directory entry overrun - offset=34816, inode=2538880996, rec_len=34812, size=128 fake=0
EXT4-fs error (device loop1): empty_inline_dir:1835: inode #12: block 7: comm syz-executor210: bad entry in directory: directory entry overrun - offset=4, inode=2538880996, rec_len=34812, size=60 fake=0
EXT4-fs warning (device loop1): empty_inline_dir:1842: bad inline directory (dir #12) - inode 2538880996, rec_len 34812, name_len 234inline size 60
EXT4-fs error (device loop1): ext4_inlinedir_to_tree:1439: inode #12: block 7: comm syz-executor210: path /root/syzkaller.a4CAkU/0/file0/file0: bad entry in directory: directory entry overrun - offset=34816, inode=2538880996, rec_len=34812, size=128 fake=0
EXT4-fs error (device loop1): empty_inline_dir:1835: inode #12: block 7: comm syz-executor210: bad entry in directory: directory entry overrun - offset=4, inode=2538880996, rec_len=34812, size=60 fake=0
EXT4-fs warning (device loop1): empty_inline_dir:1842: bad inline directory (dir #12) - inode 2538880996, rec_len 34812, name_len 234inline size 60
EXT4-fs error (device loop1): ext4_inlinedir_to_tree:1439: inode #12: block 7: comm syz-executor210: path /root/syzkaller.a4CAkU/0/file0/file0: bad entry in directory: directory entry overrun - offset=34816, inode=2538880996, rec_len=34812, size=128 fake=0
EXT4-fs error (device loop1): empty_inline_dir:1835: inode #12: block 7: comm syz-executor210: bad entry in directory: directory entry overrun - offset=4, inode=2538880996, rec_len=34812, size=60 fake=0
EXT4-fs warning (device loop1): empty_inline_dir:1842: bad inline directory (dir #12) - inode 2538880996, rec_len 34812, name_len 234inline size 60
EXT4-fs warning (device loop1): empty_inline_dir:1842: bad inline directory (dir #12) - inode 2538880996, rec_len 34812, name_len 234inline size 60
EXT4-fs warning (device loop1): empty_inline_dir:1842: bad inline directory (dir #12) - inode 2538880996, rec_len 34812, name_len 234inline size 60
EXT4-fs warning (device loop1): empty_inline_dir:1842: bad inline directory (dir #12) - inode 2538880996, rec_len 34812, name_len 234inline size 60
EXT4-fs warning (device loop1): empty_inline_dir:1842: bad inline directory (dir #12) - inode 2538880996, rec_len 34812, name_len 234inline size 60
EXT4-fs warning (device loop1): empty_inline_dir:1842: bad inline directory (dir #12) - inode 2538880996, rec_len 34812, name_len 234inline size 60


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