syzbot


KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio

Status: upstream: reported C repro on 2020/10/24 16:43
Reported-by: syzbot+41e0a5eed02e2971ae90@syzkaller.appspotmail.com
First crash: 837d, last: 26d

Fix bisection: failed (bisect log)
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio C error 14 113d 825d 0/1 upstream: reported C repro on 2020/11/05 19:13
android-54 KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio C 6 667d 728d 0/2 upstream: reported C repro on 2021/02/10 13:44

Sample crash report:
RBP: 00007ffc2483e9b0 R08: 0000000000000001 R09: 00007fae72050031
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000006
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
kvm: failed to shrink bus, removing it completely
==================================================================
BUG: KASAN: use-after-free in kvm_vm_ioctl_unregister_coalesced_mmio+0x217/0x280 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:178
Read of size 8 at addr ffff8880a9277200 by task syz-executor179/7971

CPU: 0 PID: 7971 Comm: syz-executor179 Not tainted 4.14.295-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022
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 mm/kasan/report.c:409 [inline]
 __asan_report_load8_noabort+0x68/0x70 mm/kasan/report.c:430
 kvm_vm_ioctl_unregister_coalesced_mmio+0x217/0x280 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:178
 kvm_vm_ioctl+0x77d/0x1420 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3132
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x75a/0xff0 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x7fae72096759
RSP: 002b:00007ffc2483e9a8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007fae72096759
RDX: 00000000200000c0 RSI: 000000004010ae68 RDI: 0000000000000004
RBP: 00007ffc2483e9b0 R08: 0000000000000001 R09: 00007fae72050031
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000006
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 7971:
 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
 kmem_cache_alloc_trace+0x131/0x3d0 mm/slab.c:3618
 kmalloc include/linux/slab.h:488 [inline]
 kzalloc include/linux/slab.h:661 [inline]
 kvm_vm_ioctl_register_coalesced_mmio+0x51/0x330 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:146
 kvm_vm_ioctl+0x795/0x1420 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3123
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x75a/0xff0 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb

Freed by task 7971:
 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
 kvm_iodevice_destructor include/kvm/iodev.h:73 [inline]
 kvm_io_bus_unregister_dev.cold+0xd8/0xf8 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3755
 kvm_vm_ioctl_unregister_coalesced_mmio+0x17d/0x280 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:180
 kvm_vm_ioctl+0x77d/0x1420 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3132
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x75a/0xff0 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb

The buggy address belongs to the object at ffff8880a9277200
 which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes inside of
 64-byte region [ffff8880a9277200, ffff8880a9277240)
The buggy address belongs to the page:
page:ffffea0002a49dc0 count:1 mapcount:0 mapping:ffff8880a9277000 index:0xffff8880a9277380
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffff8880a9277000 ffff8880a9277380 000000010000001f
raw: ffffea0002a5a420 ffffea0002a30120 ffff88813fe74340 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a9277100: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
 ffff8880a9277180: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff8880a9277200: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                   ^
 ffff8880a9277280: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff8880a9277300: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================

Crashes (21):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci2-linux-4-14 2022/10/18 21:07 linux-4.14.y 9d5c0b3a8e1a b31320fc .config console log report syz C [disk image] [vmlinux] KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-linux-4-14 2022/06/30 20:46 linux-4.14.y f051383ef03b 1434eec0 .config console log report syz C KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-linux-4-14 2020/10/24 16:57 linux-4.14.y 5b7a52cd2eef a1839e81 .config console log report syz C
ci2-linux-4-14 2023/01/14 08:28 linux-4.14.y c4215ee4771b 529798b0 .config console log report info [disk image] [vmlinux] [kernel image] KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-linux-4-14 2022/10/18 17:07 linux-4.14.y 9d5c0b3a8e1a b31320fc .config console log report info [disk image] [vmlinux] KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-linux-4-14 2022/03/23 22:41 linux-4.14.y 004bfaafc45c 5ff41e94 .config console log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-linux-4-14 2022/01/24 11:27 linux-4.14.y 4ba8e26127c3 214351e1 .config console log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-linux-4-14 2022/01/14 23:48 linux-4.14.y 4ba8e26127c3 53e00b45 .config console log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-linux-4-14 2021/05/18 17:07 linux-4.14.y 7d7d1c0ab3eb a343ba6b .config console log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-linux-4-14 2021/05/16 11:19 linux-4.14.y 7d7d1c0ab3eb f54a5c09 .config console log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-linux-4-14 2021/05/13 09:43 linux-4.14.y 7d7d1c0ab3eb ed7d41c5 .config console log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-linux-4-14 2021/04/23 09:03 linux-4.14.y cf256fbcbe34 590921a5 .config console log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-linux-4-14 2021/04/17 21:15 linux-4.14.y cf256fbcbe34 7e2b734b .config console log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-linux-4-14 2021/03/31 16:38 linux-4.14.y bd634aa64163 6a81331a .config console log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-linux-4-14 2021/03/04 15:20 linux-4.14.y 397a88b2cc86 d7e4e604 .config console log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-linux-4-14 2021/02/26 21:10 linux-4.14.y 3242aa3a635c 4c37c133 .config console log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-linux-4-14 2021/02/05 01:45 linux-4.14.y 2c8a3fceddf0 23a562df .config console log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-linux-4-14 2021/01/25 10:43 linux-4.14.y 2d2791fce891 52e37319 .config console log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-linux-4-14 2020/12/26 04:31 linux-4.14.y 3f2ecb86cb90 821e0b09 .config console log report info
ci2-linux-4-14 2020/11/05 19:12 linux-4.14.y 6b6446efedb2 cba33199 .config console log report info
ci2-linux-4-14 2020/10/24 16:43 linux-4.14.y 5b7a52cd2eef a1839e81 .config console log report info
* Struck through repros no longer work on HEAD.