KASAN: use-after-free Write in ext4_write_inline_data

11 views
Skip to first unread message

syzbot

unread,
Feb 4, 2021, 11:01:19 AM2/4/21
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 2c8a3fce Linux 4.14.218
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1524eea0d00000
kernel config: https://syzkaller.appspot.com/x/.config?x=80e596b8b0902d96
dashboard link: https://syzkaller.appspot.com/bug?extid=4f5051bdd848bd35a6b8
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12a3103cd00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1401c040d00000

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

EXT4-fs (loop0): mounted filesystem without journal. Opts: ,errors=continue
==================================================================
BUG: KASAN: use-after-free in memcpy include/linux/string.h:372 [inline]
BUG: KASAN: use-after-free in ext4_write_inline_data+0x2ae/0x380 fs/ext4/inline.c:251
Write of size 70 at addr ffff8880b61074ef by task syz-executor568/7952

CPU: 0 PID: 7952 Comm: syz-executor568 Not tainted 4.14.218-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x1b2/0x281 lib/dump_stack.c:58
print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
kasan_report_error.cold+0x8a/0x191 mm/kasan/report.c:351
kasan_report+0x6f/0x80 mm/kasan/report.c:409
memcpy+0x35/0x50 mm/kasan/kasan.c:303
memcpy include/linux/string.h:372 [inline]
ext4_write_inline_data+0x2ae/0x380 fs/ext4/inline.c:251
ext4_write_inline_data_end+0x1d3/0x490 fs/ext4/inline.c:760
ext4_write_end+0x18d/0xca0 fs/ext4/inode.c:1423
ext4_da_write_end+0x6da/0x8e0 fs/ext4/inode.c:3178
generic_perform_write+0x268/0x420 mm/filemap.c:3066
__generic_file_write_iter+0x227/0x590 mm/filemap.c:3180
ext4_file_write_iter+0x276/0xd20 fs/ext4/file.c:270
call_write_iter include/linux/fs.h:1778 [inline]
new_sync_write fs/read_write.c:469 [inline]
__vfs_write+0x44c/0x630 fs/read_write.c:482
vfs_write+0x17f/0x4d0 fs/read_write.c:544
SYSC_write fs/read_write.c:590 [inline]
SyS_write+0xf2/0x210 fs/read_write.c:582
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x44a509
RSP: 002b:00007f0582f64208 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00000000004cd428 RCX: 000000000044a509
RDX: 0000000000000082 RSI: 0000000020000180 RDI: 0000000000000008
RBP: 00000000004cd420 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000004cd42c
R13: 00007ffc529d143f R14: 00007f0582f64300 R15: 0000000000022000

Allocated by task 1:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
__do_kmalloc mm/slab.c:3720 [inline]
__kmalloc+0x15a/0x400 mm/slab.c:3729
kmalloc include/linux/slab.h:493 [inline]
do_tty_write drivers/tty/tty_io.c:941 [inline]
tty_write+0x4e0/0x740 drivers/tty/tty_io.c:1043
redirected_tty_write+0x9c/0xb0 drivers/tty/tty_io.c:1064
do_loop_readv_writev fs/read_write.c:698 [inline]
do_loop_readv_writev fs/read_write.c:682 [inline]
do_iter_write+0x3da/0x550 fs/read_write.c:956
vfs_writev+0x125/0x290 fs/read_write.c:999
do_writev+0xfc/0x2c0 fs/read_write.c:1034
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb

Freed by task 3517:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3496 [inline]
kfree+0xc9/0x250 mm/slab.c:3815
free_tty_struct drivers/tty/tty_io.c:172 [inline]
release_one_tty+0x2cf/0x3e0 drivers/tty/tty_io.c:1455
process_one_work+0x793/0x14a0 kernel/workqueue.c:2116
worker_thread+0x5cc/0xff0 kernel/workqueue.c:2250
kthread+0x30d/0x420 kernel/kthread.c:232
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

The buggy address belongs to the object at ffff8880b6107200
which belongs to the cache kmalloc-1024 of size 1024
The buggy address is located 751 bytes inside of
1024-byte region [ffff8880b6107200, ffff8880b6107600)
The buggy address belongs to the page:
page:ffffea0002d84180 count:1 mapcount:0 mapping:ffff8880b6106000 index:0x0 compound_mapcount: 0
flags: 0xfff00000008100(slab|head)
raw: 00fff00000008100 ffff8880b6106000 0000000000000000 0000000100000007
raw: ffffea00025bb920 ffffea00025bf6a0 ffff88813fe80ac0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880b6107380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880b6107400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880b6107480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880b6107500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880b6107580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
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.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches
Reply all
Reply to author
Forward
0 new messages