syzbot


KASAN: slab-out-of-bounds Write in ext4_write_inline_data

Status: fixed on 2021/10/06 16:08
Reported-by: syzbot+ee003b75a408d5f370bb@syzkaller.appspotmail.com
Fix commit: c481607ba522 ext4: fix race writing to an inline_data file while its xattrs are changing
First crash: 1168d, last: 962d
Fix bisection: fixed by (bisect log) :
commit c481607ba522e31e6ed01efefc19cc1d0e0a46fa
Author: Theodore Ts'o <tytso@mit.edu>
Date: Sat Aug 21 03:44:17 2021 +0000

  ext4: fix race writing to an inline_data file while its xattrs are changing

  
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Write in ext4_write_inline_data C 6 423d 1175d 0/1 upstream: reported C repro on 2021/02/04 16:01
upstream KASAN: use-after-free Write in ext4_write_inline_data ext4 C done error 1 987d 983d 0/26 auto-obsoleted due to no activity on 2022/10/01 15:10
Fix bisection attempts (7)
Created Duration User Patch Repo Result
2021/10/06 11:58 3h45m bisect fix linux-4.19.y job log (1)
2021/09/06 11:26 31m bisect fix linux-4.19.y job log (0) log
2021/08/07 10:59 27m bisect fix linux-4.19.y job log (0) log
2021/07/08 10:36 22m bisect fix linux-4.19.y job log (0) log
2021/06/04 22:19 23m bisect fix linux-4.19.y job log (0) log
2021/04/13 06:44 22m bisect fix linux-4.19.y job log (0) log
2021/03/14 06:20 23m bisect fix linux-4.19.y job log (0) log

Sample crash report:
EXT4-fs (loop0): mounted filesystem without journal. Opts: ,errors=continue
==================================================================
BUG: KASAN: slab-out-of-bounds in memcpy syzkaller/managers/linux-4-19/kernel/./include/linux/string.h:373 [inline]
BUG: KASAN: slab-out-of-bounds in ext4_write_inline_data+0x300/0x3d0 syzkaller/managers/linux-4-19/kernel/fs/ext4/inline.c:245
Write of size 70 at addr ffff88809888a4ef by task syz-executor460/8111

CPU: 1 PID: 8111 Comm: syz-executor460 Not tainted 4.19.172-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack syzkaller/managers/linux-4-19/kernel/lib/dump_stack.c:77 [inline]
 dump_stack+0x1fc/0x2ef syzkaller/managers/linux-4-19/kernel/lib/dump_stack.c:118
 print_address_description.cold+0x54/0x219 syzkaller/managers/linux-4-19/kernel/mm/kasan/report.c:256
 kasan_report_error.cold+0x8a/0x1b9 syzkaller/managers/linux-4-19/kernel/mm/kasan/report.c:354
 kasan_report+0x8f/0xa0 syzkaller/managers/linux-4-19/kernel/mm/kasan/report.c:412
 memcpy+0x35/0x50 syzkaller/managers/linux-4-19/kernel/mm/kasan/kasan.c:303
 memcpy syzkaller/managers/linux-4-19/kernel/./include/linux/string.h:373 [inline]
 ext4_write_inline_data+0x300/0x3d0 syzkaller/managers/linux-4-19/kernel/fs/ext4/inline.c:245
 ext4_write_inline_data_end+0x220/0x640 syzkaller/managers/linux-4-19/kernel/fs/ext4/inline.c:754
 ext4_write_end+0x1de/0xec0 syzkaller/managers/linux-4-19/kernel/fs/ext4/inode.c:1424
 ext4_da_write_end+0x860/0xa70 syzkaller/managers/linux-4-19/kernel/fs/ext4/inode.c:3171
 generic_perform_write+0x2ae/0x4d0 syzkaller/managers/linux-4-19/kernel/mm/filemap.c:3181
 __generic_file_write_iter+0x24b/0x610 syzkaller/managers/linux-4-19/kernel/mm/filemap.c:3295
 ext4_file_write_iter+0x2fe/0xf20 syzkaller/managers/linux-4-19/kernel/fs/ext4/file.c:272
 call_write_iter syzkaller/managers/linux-4-19/kernel/./include/linux/fs.h:1821 [inline]
 new_sync_write syzkaller/managers/linux-4-19/kernel/fs/read_write.c:474 [inline]
 __vfs_write+0x51b/0x770 syzkaller/managers/linux-4-19/kernel/fs/read_write.c:487
 vfs_write+0x1f3/0x540 syzkaller/managers/linux-4-19/kernel/fs/read_write.c:549
 ksys_write+0x12b/0x2a0 syzkaller/managers/linux-4-19/kernel/fs/read_write.c:599
 do_syscall_64+0xf9/0x620 syzkaller/managers/linux-4-19/kernel/arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x449bd9
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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fadf66392f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00000000004cc420 RCX: 0000000000449bd9
RDX: 0000000000000082 RSI: 0000000020000180 RDI: 0000000000000008
RBP: 000000000049be58 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0030656c69662f2e
R13: 024645fc87234f45 R14: 26e1d8b70aefbc5b R15: 00000000004cc428

Allocated by task 1:
 kmem_cache_alloc+0x122/0x370 syzkaller/managers/linux-4-19/kernel/mm/slab.c:3559
 getname_flags+0xce/0x590 syzkaller/managers/linux-4-19/kernel/fs/namei.c:140
 do_sys_open+0x26c/0x520 syzkaller/managers/linux-4-19/kernel/fs/open.c:1079
 do_syscall_64+0xf9/0x620 syzkaller/managers/linux-4-19/kernel/arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 1:
 __cache_free syzkaller/managers/linux-4-19/kernel/mm/slab.c:3503 [inline]
 kmem_cache_free+0x7f/0x260 syzkaller/managers/linux-4-19/kernel/mm/slab.c:3765
 putname+0xe1/0x120 syzkaller/managers/linux-4-19/kernel/fs/namei.c:261
 do_sys_open+0x2ba/0x520 syzkaller/managers/linux-4-19/kernel/fs/open.c:1094
 do_syscall_64+0xf9/0x620 syzkaller/managers/linux-4-19/kernel/arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88809888ab80
 which belongs to the cache names_cache of size 4096
The buggy address is located 1681 bytes to the left of
 4096-byte region [ffff88809888ab80, ffff88809888bb80)
The buggy address belongs to the page:
page:ffffea0002622280 count:1 mapcount:0 mapping:ffff88813be83e40 index:0x0 compound_mapcount: 0
flags: 0xfff00000008100(slab|head)
raw: 00fff00000008100 ffffea0002622208 ffffea00027a8108 ffff88813be83e40
raw: 0000000000000000 ffff88809888ab80 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809888a380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88809888a400: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88809888a480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                                                          ^
 ffff88809888a500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88809888a580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/02/12 05:53 linux-4.19.y 811218eceeaa a5f86b15 .config console log report syz C ci2-linux-4-19 KASAN: slab-out-of-bounds Write in ext4_write_inline_data
2021/06/08 07:47 linux-4.19.y 1722257b8ece b718257f .config console log report syz C ci2-linux-4-19 KASAN: use-after-free Write in ext4_write_inline_data
2021/05/05 22:05 linux-4.19.y 97a8651cadce 06c27ff5 .config console log report info ci2-linux-4-19 KASAN: slab-out-of-bounds Write in ext4_write_inline_data
* Struck through repros no longer work on HEAD.