KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio

6 views
Skip to first unread message

syzbot

unread,
Nov 5, 2020, 2:13:16 PM11/5/20
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: b94de4d1 Linux 4.19.155
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=16d8be1a500000
kernel config: https://syzkaller.appspot.com/x/.config?x=252047157acf1cb1
dashboard link: https://syzkaller.appspot.com/bug?extid=77c67c409dad0ba32099
compiler: gcc (GCC) 10.1.0-syz 20200507

Unfortunately, I don't have any reproducer for this issue yet.

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

kvm: failed to shrink bus, removing it completely
==================================================================
BUG: KASAN: use-after-free in kvm_vm_ioctl_unregister_coalesced_mmio+0x25a/0x2c0 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:178
Read of size 8 at addr ffff8880b5b47b80 by task syz-executor.1/28351

CPU: 1 PID: 28351 Comm: syz-executor.1 Not tainted 4.19.155-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1fc/0x2fe lib/dump_stack.c:118
print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
kasan_report_error.cold+0x8a/0x1c7 mm/kasan/report.c:354
kasan_report mm/kasan/report.c:412 [inline]
__asan_report_load8_noabort+0x88/0x90 mm/kasan/report.c:433
kvm_vm_ioctl_unregister_coalesced_mmio+0x25a/0x2c0 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:178
kvm_vm_ioctl+0x532/0x16e0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3252
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:501 [inline]
do_vfs_ioctl+0xcdb/0x12e0 fs/ioctl.c:688
ksys_ioctl+0x9b/0xc0 fs/ioctl.c:705
__do_sys_ioctl fs/ioctl.c:712 [inline]
__se_sys_ioctl fs/ioctl.c:710 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:710
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45deb9
Code: 0d b4 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 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 0f 83 db b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fecdb506c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000012740 RCX: 000000000045deb9
RDX: 0000000020000180 RSI: 000000004010ae68 RDI: 0000000000000004
RBP: 00007fecdb506ca0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffe0461dccf R14: 00007fecdb5079c0 R15: 000000000118bf2c

Allocated by task 28351:
kmem_cache_alloc_trace+0x12f/0x380 mm/slab.c:3625
kmalloc include/linux/slab.h:515 [inline]
kzalloc include/linux/slab.h:709 [inline]
kvm_vm_ioctl_register_coalesced_mmio+0x51/0x350 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:146
kvm_vm_ioctl+0xc63/0x16e0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3243
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:501 [inline]
do_vfs_ioctl+0xcdb/0x12e0 fs/ioctl.c:688
ksys_ioctl+0x9b/0xc0 fs/ioctl.c:705
__do_sys_ioctl fs/ioctl.c:712 [inline]
__se_sys_ioctl fs/ioctl.c:710 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:710
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 28351:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
kvm_iodevice_destructor include/kvm/iodev.h:73 [inline]
kvm_io_bus_unregister_dev.cold+0xf0/0x110 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3875
kvm_vm_ioctl_unregister_coalesced_mmio+0x1be/0x2c0 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:180
kvm_vm_ioctl+0x532/0x16e0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3252
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:501 [inline]
do_vfs_ioctl+0xcdb/0x12e0 fs/ioctl.c:688
ksys_ioctl+0x9b/0xc0 fs/ioctl.c:705
__do_sys_ioctl fs/ioctl.c:712 [inline]
__se_sys_ioctl fs/ioctl.c:710 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:710
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880b5b47b80
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes inside of
64-byte region [ffff8880b5b47b80, ffff8880b5b47bc0)
The buggy address belongs to the page:
page:ffffea0002d6d1c0 count:1 mapcount:0 mapping:ffff88813bff0340 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffffea00026d2e08 ffffea0002a9bf48 ffff88813bff0340
raw: 0000000000000000 ffff8880b5b47000 0000000100000020 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880b5b47a80: 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc
ffff8880b5b47b00: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
>ffff8880b5b47b80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
^
ffff8880b5b47c00: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
ffff8880b5b47c80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================


---
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

unread,
Nov 5, 2020, 2:26:16 PM11/5/20
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: b94de4d1 Linux 4.19.155
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=15334d8a500000
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1448a3a8500000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10e00532500000

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

R10: 0000000000000000 R11: 0000000000000246 R12: 00000000004020e0
R13: 0000000000402170 R14: 0000000000000000 R15: 0000000000000000
kvm: failed to shrink bus, removing it completely
==================================================================
BUG: KASAN: use-after-free in kvm_vm_ioctl_unregister_coalesced_mmio+0x25a/0x2c0 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:178
Read of size 8 at addr ffff88809858b200 by task syz-executor941/8113

CPU: 1 PID: 8113 Comm: syz-executor941 Not tainted 4.19.155-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1fc/0x2fe lib/dump_stack.c:118
print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
kasan_report_error.cold+0x8a/0x1c7 mm/kasan/report.c:354
kasan_report mm/kasan/report.c:412 [inline]
__asan_report_load8_noabort+0x88/0x90 mm/kasan/report.c:433
kvm_vm_ioctl_unregister_coalesced_mmio+0x25a/0x2c0 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:178
kvm_vm_ioctl+0x532/0x16e0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3252
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:501 [inline]
do_vfs_ioctl+0xcdb/0x12e0 fs/ioctl.c:688
ksys_ioctl+0x9b/0xc0 fs/ioctl.c:705
__do_sys_ioctl fs/ioctl.c:712 [inline]
__se_sys_ioctl fs/ioctl.c:710 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:710
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x440879
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 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 0f 83 db 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffc2f0024d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007ffc2f0024e0 RCX: 0000000000440879
RDX: 0000000020000180 RSI: 000000004010ae68 RDI: 0000000000000004
RBP: 0000000000000005 R08: 0000000000000001 R09: 00007ffc2f000031
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000004020e0
R13: 0000000000402170 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 8113:
kmem_cache_alloc_trace+0x12f/0x380 mm/slab.c:3625
kmalloc include/linux/slab.h:515 [inline]
kzalloc include/linux/slab.h:709 [inline]
kvm_vm_ioctl_register_coalesced_mmio+0x51/0x350 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:146
kvm_vm_ioctl+0xc63/0x16e0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3243
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:501 [inline]
do_vfs_ioctl+0xcdb/0x12e0 fs/ioctl.c:688
ksys_ioctl+0x9b/0xc0 fs/ioctl.c:705
__do_sys_ioctl fs/ioctl.c:712 [inline]
__se_sys_ioctl fs/ioctl.c:710 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:710
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8113:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
kvm_iodevice_destructor include/kvm/iodev.h:73 [inline]
kvm_io_bus_unregister_dev.cold+0xf0/0x110 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3875
kvm_vm_ioctl_unregister_coalesced_mmio+0x1be/0x2c0 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:180
kvm_vm_ioctl+0x532/0x16e0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3252
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:501 [inline]
do_vfs_ioctl+0xcdb/0x12e0 fs/ioctl.c:688
ksys_ioctl+0x9b/0xc0 fs/ioctl.c:705
__do_sys_ioctl fs/ioctl.c:712 [inline]
__se_sys_ioctl fs/ioctl.c:710 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:710
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88809858b200
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes inside of
64-byte region [ffff88809858b200, ffff88809858b240)
The buggy address belongs to the page:
page:ffffea00026162c0 count:1 mapcount:0 mapping:ffff88813bff0340 index:0xffff88809858bf80
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffff88813bff1338 ffffea000261c508 ffff88813bff0340
raw: ffff88809858bf80 ffff88809858b000 000000010000001e 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88809858b100: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
ffff88809858b180: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff88809858b200: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
^
ffff88809858b280: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff88809858b300: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================

Reply all
Reply to author
Forward
0 new messages