syzbot


KASAN: use-after-free Read in ext4_convert_inline_data_nolock

Status: upstream: reported C repro on 2023/05/21 13:36
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+f6a8aa7e307cf6ee835e@syzkaller.appspotmail.com
First crash: 369d, last: 33d
Bug presence (1)
Date Name Commit Repro Result
2023/05/21 upstream (ToT) 0dd2a6fb1e34 C [report] KASAN: slab-out-of-bounds Read in ext4_convert_inline_data_nolock
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-use-after-free Read in ext4_convert_inline_data_nolock ext4 C error done 7 147d 424d 26/26 fixed on 2024/02/03 12:44
android-5-10 KASAN: use-after-free Read in ext4_convert_inline_data_nolock syz 1 24d 24d 0/2 premoderation: reported syz repro on 2024/04/30 09:18
android-6-1 KASAN: use-after-free Read in ext4_convert_inline_data_nolock origin:upstream C 1 10d 24d 0/2 upstream: reported C repro on 2024/04/30 15:29
linux-6.1 KASAN: use-after-free Read in ext4_convert_inline_data_nolock origin:upstream C 2 32d 405d 0/3 upstream: reported C repro on 2023/04/15 09:27
android-54 KASAN: use-after-free Read in ext4_convert_inline_data_nolock C 1 10d 24d 0/2 upstream: reported C repro on 2024/04/30 09:11
Fix bisection attempts (9)
Created Duration User Patch Repo Result
2024/04/21 12:21 1h02m bisect fix linux-5.15.y job log (0) log
2024/03/21 01:15 1h08m bisect fix linux-5.15.y job log (0) log
2024/02/19 23:46 57m bisect fix linux-5.15.y job log (0) log
2024/01/09 18:50 55m bisect fix linux-5.15.y job log (0) log
2023/12/10 17:51 56m bisect fix linux-5.15.y job log (0) log
2023/11/10 11:12 1h03m bisect fix linux-5.15.y job log (0) log
2023/10/07 05:00 2h02m bisect fix linux-5.15.y job log (0) log
2023/08/12 14:37 1h36m bisect fix linux-5.15.y job log (0) log
2023/06/21 17:30 41m bisect fix linux-5.15.y job log (0) log

Sample crash report:
loop0: detected capacity change from 0 to 2048
EXT4-fs (loop0): mounted filesystem without journal. Opts: ,errors=continue. Quota mode: none.
==================================================================
BUG: KASAN: use-after-free in ext4_read_inline_data fs/ext4/inline.c:209 [inline]
BUG: KASAN: use-after-free in ext4_convert_inline_data_nolock+0x319/0xda0 fs/ext4/inline.c:1223
Read of size 20 at addr ffff88801df5a1a3 by task syz-executor322/3498

CPU: 1 PID: 3498 Comm: syz-executor322 Not tainted 5.15.112-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb 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+0x25/0x60 mm/kasan/shadow.c:65
 ext4_read_inline_data fs/ext4/inline.c:209 [inline]
 ext4_convert_inline_data_nolock+0x319/0xda0 fs/ext4/inline.c:1223
 ext4_convert_inline_data+0x4cf/0x610 fs/ext4/inline.c:2056
 ext4_fallocate+0x148/0x20c0 fs/ext4/extents.c:4705
 vfs_fallocate+0x54a/0x6b0 fs/open.c:308
 ksys_fallocate fs/open.c:331 [inline]
 __do_sys_fallocate fs/open.c:339 [inline]
 __se_sys_fallocate fs/open.c:337 [inline]
 __x64_sys_fallocate+0xb9/0x100 fs/open.c:337
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7fe994521299
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 81 14 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff77e698e8 EFLAGS: 00000246 ORIG_RAX: 000000000000011d
RAX: ffffffffffffffda RBX: 00007fe994596740 RCX: 00007fe994521299
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000004
RBP: 0000000000000001 R08: 001c00000000000c R09: 001c00000000000c
R10: 0000000000008000 R11: 0000000000000246 R12: 0000000000000004
R13: 0000000000000003 R14: 00007fff77e69907 R15: 00007fff77e6990a
 </TASK>

Allocated by task 2967:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 ____kasan_kmalloc+0xba/0xf0 mm/kasan/common.c:513
 kasan_kmalloc include/linux/kasan.h:264 [inline]
 __kmalloc+0x168/0x300 mm/slub.c:4407
 kmalloc include/linux/slab.h:596 [inline]
 tomoyo_realpath_from_path+0xd8/0x5e0 security/tomoyo/realpath.c:254
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_check_open_permission+0x22c/0x490 security/tomoyo/file.c:771
 security_file_open+0x5f/0xa0 security/security.c:1650
 do_dentry_open+0x315/0xfb0 fs/open.c:813
 do_open fs/namei.c:3538 [inline]
 path_openat+0x2702/0x2f20 fs/namei.c:3672
 do_filp_open+0x21c/0x460 fs/namei.c:3699
 do_sys_openat2+0x13b/0x500 fs/open.c:1211
 do_sys_open fs/open.c:1227 [inline]
 __do_sys_openat fs/open.c:1243 [inline]
 __se_sys_openat fs/open.c:1238 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1238
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Freed by task 2967:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kfree+0xf1/0x270 mm/slub.c:4559
 tomoyo_realpath_from_path+0x5ad/0x5e0 security/tomoyo/realpath.c:291
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_check_open_permission+0x22c/0x490 security/tomoyo/file.c:771
 security_file_open+0x5f/0xa0 security/security.c:1650
 do_dentry_open+0x315/0xfb0 fs/open.c:813
 do_open fs/namei.c:3538 [inline]
 path_openat+0x2702/0x2f20 fs/namei.c:3672
 do_filp_open+0x21c/0x460 fs/namei.c:3699
 do_sys_openat2+0x13b/0x500 fs/open.c:1211
 do_sys_open fs/open.c:1227 [inline]
 __do_sys_openat fs/open.c:1243 [inline]
 __se_sys_openat fs/open.c:1238 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1238
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

The buggy address belongs to the object at ffff88801df5a000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 419 bytes inside of
 4096-byte region [ffff88801df5a000, ffff88801df5b000)
The buggy address belongs to the page:
page:ffffea000077d600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1df58
head:ffffea000077d600 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888011c42140
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 2967, ts 22174041375, free_ts 22118743760
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x322a/0x33c0 mm/page_alloc.c:4159
 __alloc_pages+0x272/0x700 mm/page_alloc.c:5421
 alloc_slab_page mm/slub.c:1775 [inline]
 allocate_slab mm/slub.c:1912 [inline]
 new_slab+0xbb/0x4b0 mm/slub.c:1975
 ___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
 __slab_alloc mm/slub.c:3095 [inline]
 slab_alloc_node mm/slub.c:3186 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 __kmalloc+0x1c9/0x300 mm/slub.c:4403
 kmalloc include/linux/slab.h:596 [inline]
 tomoyo_realpath_from_path+0xd8/0x5e0 security/tomoyo/realpath.c:254
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_number_perm+0x225/0x810 security/tomoyo/file.c:723
 tomoyo_path_mknod+0x172/0x1b0 security/tomoyo/tomoyo.c:239
 security_path_mknod+0xf1/0x150 security/security.c:1147
 may_o_create fs/namei.c:3214 [inline]
 lookup_open fs/namei.c:3355 [inline]
 open_last_lookups fs/namei.c:3462 [inline]
 path_openat+0xc73/0x2f20 fs/namei.c:3669
 do_filp_open+0x21c/0x460 fs/namei.c:3699
 do_sys_openat2+0x13b/0x500 fs/open.c:1211
 do_sys_open fs/open.c:1227 [inline]
 __do_sys_openat fs/open.c:1243 [inline]
 __se_sys_openat fs/open.c:1238 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1238
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
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+0x95/0x2d0 mm/page_alloc.c:3396
 do_slab_free mm/slub.c:3487 [inline]
 ___cache_free+0xe3/0x100 mm/slub.c:3506
 qlist_free_all+0x36/0x90 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xc0 mm/kasan/common.c:444
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0xf3/0x280 mm/slub.c:3233
 getname_flags+0xb8/0x4e0 fs/namei.c:138
 do_sys_openat2+0xd2/0x500 fs/open.c:1205
 do_sys_open fs/open.c:1227 [inline]
 __do_sys_openat fs/open.c:1243 [inline]
 __se_sys_openat fs/open.c:1238 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1238
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Memory state around the buggy address:
 ffff88801df5a080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88801df5a100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88801df5a180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff88801df5a200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88801df5a280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/05/21 13:35 linux-5.15.y 9d6bde853685 4bce1a3e .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-5-15-kasan KASAN: use-after-free Read in ext4_convert_inline_data_nolock
* Struck through repros no longer work on HEAD.