syzbot


KASAN: use-after-free Read in ext4_inlinedir_to_tree

Status: upstream: reported C repro on 2024/04/14 03:44
Reported-by: syzbot+52813a2561e5222492ee@syzkaller.appspotmail.com
First crash: 67d, last: 53d
Fix bisection: failed (error log, bisect log)
  
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-54 KASAN: slab-out-of-bounds Read in ext4_inlinedir_to_tree C 1 53d 67d 0/2 upstream: reported C repro on 2024/04/14 03:10
upstream KMSAN: uninit-value in number (4) kernel C 7189 575d 953d 0/27 closed as invalid on 2022/11/28 10:01
android-6-1 KASAN: slab-out-of-bounds Read in ext4_inlinedir_to_tree origin:upstream C error 1 53d 67d 0/2 upstream: reported C repro on 2024/04/14 08:35
upstream KMSAN: uninit-value in ext4_inlinedir_to_tree ext4 C 267 6d02h 51d 0/27 upstream: reported C repro on 2024/04/29 16:05
upstream KMSAN: uninit-value in htree_dirblock_to_tree ext4 204 403d 534d 22/27 fixed on 2023/07/01 16:05
Last patch testing requests (1)
Created Duration User Patch Repo Result
2024/04/28 11:20 4m retest repro android13-5.10-lts report log

Sample crash report:
==================================================================
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

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/04/14 03:43 android13-5.10-lts 4e1bc8d8e8ae c8349e48 .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci2-android-5-10 KASAN: use-after-free Read in ext4_inlinedir_to_tree
* Struck through repros no longer work on HEAD.