syzbot


KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio

Status: upstream: reported C repro on 2021/02/10 13:44
Reported-by: syzbot+0a54a840b5c4790624a7@syzkaller.appspotmail.com
First crash: 662d, last: 600d
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 46d 758d 0/1 upstream: reported C repro on 2020/11/05 19:13
linux-4.14 KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio C error 20 46d 770d 0/1 upstream: reported C repro on 2020/10/24 16:43

Sample crash report:
RBP: 00007fff0459d490 R08: 0000000000000001 R09: 0000000000400031
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000005
R13: 0000000000000000 R14: 00000000004ad018 R15: 0000000000400488
kvm: failed to shrink bus, removing it completely
==================================================================
BUG: KASAN: use-after-free in kvm_vm_ioctl_unregister_coalesced_mmio+0xe6/0x3a0 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:187
Read of size 8 at addr ffff8881ea59ea00 by task syz-executor474/337

CPU: 1 PID: 337 Comm: syz-executor474 Not tainted 5.4.96-syzkaller-00126-g72d1876a39cf #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+0x1d8/0x24e lib/dump_stack.c:118
 print_address_description+0x9b/0x650 mm/kasan/report.c:374
 __kasan_report+0x182/0x1f0 mm/kasan/report.c:506
 kasan_report+0x30/0x60 mm/kasan/common.c:634
 kvm_vm_ioctl_unregister_coalesced_mmio+0xe6/0x3a0 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:187
 kvm_vm_ioctl+0x947/0x1a40 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3419
 do_vfs_ioctl+0x76a/0x1720 fs/ioctl.c:47
 ksys_ioctl fs/ioctl.c:742 [inline]
 __do_sys_ioctl fs/ioctl.c:749 [inline]
 __se_sys_ioctl fs/ioctl.c:747 [inline]
 __x64_sys_ioctl+0xd4/0x110 fs/ioctl.c:747
 do_syscall_64+0xcb/0x150 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff0459d488 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 000000000043f5a9
RDX: 00000000200000c0 RSI: 000000004010ae68 RDI: 0000000000000004
RBP: 00007fff0459d490 R08: 0000000000000001 R09: 0000000000400031
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000005
R13: 0000000000000000 R14: 00000000004ad018 R15: 0000000000400488

Allocated by task 337:
 save_stack mm/kasan/common.c:69 [inline]
 set_track mm/kasan/common.c:77 [inline]
 __kasan_kmalloc+0x137/0x1e0 mm/kasan/common.c:510
 kmalloc include/linux/slab.h:556 [inline]
 kzalloc include/linux/slab.h:690 [inline]
 kvm_vm_ioctl_register_coalesced_mmio+0x86/0x310 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:150
 kvm_vm_ioctl+0x7f2/0x1a40 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3410
 do_vfs_ioctl+0x76a/0x1720 fs/ioctl.c:47
 ksys_ioctl fs/ioctl.c:742 [inline]
 __do_sys_ioctl fs/ioctl.c:749 [inline]
 __se_sys_ioctl fs/ioctl.c:747 [inline]
 __x64_sys_ioctl+0xd4/0x110 fs/ioctl.c:747
 do_syscall_64+0xcb/0x150 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 337:
 save_stack mm/kasan/common.c:69 [inline]
 set_track mm/kasan/common.c:77 [inline]
 kasan_set_free_info mm/kasan/common.c:332 [inline]
 __kasan_slab_free+0x18a/0x240 mm/kasan/common.c:471
 slab_free mm/slub.c:3051 [inline]
 kfree+0xe0/0x660 mm/slub.c:4017
 kvm_iodevice_destructor include/kvm/iodev.h:61 [inline]
 kvm_io_bus_unregister_dev+0x377/0x470 arch/x86/kvm/../../../virt/kvm/kvm_main.c:4041
 kvm_vm_ioctl+0x947/0x1a40 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3419
 do_vfs_ioctl+0x76a/0x1720 fs/ioctl.c:47
 do_syscall_64+0xcb/0x150 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff8881ea59ea00
 which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes inside of
 64-byte region [ffff8881ea59ea00, ffff8881ea59ea40)
The buggy address belongs to the page:
page:ffffea0007a96780 refcount:1 mapcount:0 mapping:ffff8881f5c03180 index:0x0
flags: 0x8000000000000200(slab)
raw: 8000000000000200 dead000000000100 dead000000000122 ffff8881f5c03180
raw: 0000000000000000 0000000080200020 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8881ea59e900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8881ea59e980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8881ea59ea00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                   ^
 ffff8881ea59ea80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8881ea59eb00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
CPU: 1 PID: 337 Comm: syz-executor474 Tainted: G    B             5.4.96-syzkaller-00126-g72d1876a39cf #0
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1d8/0x24e lib/dump_stack.c:118
 panic+0x285/0x740 kernel/panic.c:221
 end_report mm/kasan/report.c:96 [inline]
 __kasan_report+0x1ec/0x1f0 mm/kasan/report.c:513
 kasan_report+0x30/0x60 mm/kasan/common.c:634
 kvm_vm_ioctl_unregister_coalesced_mmio+0xe6/0x3a0 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:187
 kvm_vm_ioctl+0x947/0x1a40 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3419
 do_vfs_ioctl+0x76a/0x1720 fs/ioctl.c:47
 ksys_ioctl fs/ioctl.c:742 [inline]
 __do_sys_ioctl fs/ioctl.c:749 [inline]
 __se_sys_ioctl fs/ioctl.c:747 [inline]
 __x64_sys_ioctl+0xd4/0x110 fs/ioctl.c:747
 do_syscall_64+0xcb/0x150 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x43f5a9
Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff0459d488 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 000000000043f5a9
RDX: 00000000200000c0 RSI: 000000004010ae68 RDI: 0000000000000004
RBP: 00007fff0459d490 R08: 0000000000000001 R09: 0000000000400031
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000005
R13: 0000000000000000 R14: 00000000004ad018 R15: 0000000000400488
Kernel Offset: disabled
Rebooting in 86400 seconds..

Crashes (6):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-android-5-4-kasan 2021/02/10 13:54 android12-5.4 72d1876a39cf 9c8b8541 .config log report syz C KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-android-5-4-kasan 2021/04/13 08:29 android12-5.4 3c5dbcf40ba8 6a81331a .config log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-android-5-4-kasan 2021/04/12 00:56 android12-5.4 94535fb224d4 6a81331a .config log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-android-5-4-kasan 2021/03/19 13:58 android12-5.4 63fc7efda14e 2af9d324 .config log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-android-5-4-kasan 2021/03/02 07:37 android12-5.4 000f1f482d2c 183afb6c .config log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
ci2-android-5-4-kasan 2021/02/10 13:43 android12-5.4 72d1876a39cf 9c8b8541 .config log report info KASAN: use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
* Struck through repros no longer work on HEAD.