syzbot


KASAN: use-after-free Read in kvm_put_kvm

Status: fixed on 2019/01/11 01:22
Subsystems: kvm
[Documentation on labels]
Reported-by: syzbot+f87f60bb6f13f39b54e3@syzkaller.appspotmail.com
Fix commit: 987d1149be7d KVM: fix unregistering coalesced mmio zone from wrong bus
First crash: 2039d, last: 1978d
Discussions (2)
Title Replies (including bot) Last reply
KASAN: use-after-free Read in kvm_put_kvm 4 (5) 2018/12/18 21:03
[PATCH] KVM: fix unregistering coalesced mmio zone from wrong bus 1 (1) 2018/12/17 17:36

Sample crash report:
L1TF CPU bug present and SMT on, data leak possible. See CVE-2018-3646 and https://www.kernel.org/doc/html/latest/admin-guide/l1tf.html for details.
==================================================================
BUG: KASAN: use-after-free in kvm_iodevice_destructor include/kvm/iodev.h:72 [inline]
BUG: KASAN: use-after-free in kvm_io_bus_destroy arch/x86/kvm/../../../virt/kvm/kvm_main.c:3401 [inline]
BUG: KASAN: use-after-free in kvm_destroy_vm arch/x86/kvm/../../../virt/kvm/kvm_main.c:740 [inline]
BUG: KASAN: use-after-free in kvm_put_kvm+0xd7c/0xff0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:770
Read of size 8 at addr ffff8801cd479910 by task syz-executor822/5583

CPU: 0 PID: 5583 Comm: syz-executor822 Not tainted 4.19.0-rc8-next-20181019+ #98
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+0x244/0x39d lib/dump_stack.c:113
 print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 kvm_iodevice_destructor include/kvm/iodev.h:72 [inline]
 kvm_io_bus_destroy arch/x86/kvm/../../../virt/kvm/kvm_main.c:3401 [inline]
 kvm_destroy_vm arch/x86/kvm/../../../virt/kvm/kvm_main.c:740 [inline]
 kvm_put_kvm+0xd7c/0xff0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:770
 kvm_vm_release+0x42/0x50 arch/x86/kvm/../../../virt/kvm/kvm_main.c:781
 __fput+0x3bc/0xa70 fs/file_table.c:279
 ____fput+0x15/0x20 fs/file_table.c:312
 task_work_run+0x1e8/0x2a0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0x1ad1/0x26d0 kernel/exit.c:867
 do_group_exit+0x177/0x440 kernel/exit.c:970
 __do_sys_exit_group kernel/exit.c:981 [inline]
 __se_sys_exit_group kernel/exit.c:979 [inline]
 __x64_sys_exit_group+0x3e/0x50 kernel/exit.c:979
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x43ecf8
Code: Bad RIP value.
RSP: 002b:00007ffdc564f908 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 000000000043ecf8
RDX: 0000000000000000 RSI: 000000000000003c RDI: 0000000000000000
RBP: 00000000004be5a8 R08: 00000000000000e7 R09: ffffffffffffffd0
R10: 00000000004002c8 R11: 0000000000000246 R12: 0000000000000001
R13: 00000000006d0180 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 5583:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
 kmem_cache_alloc_trace+0x152/0x750 mm/slab.c:3620
 kmalloc include/linux/slab.h:546 [inline]
 kzalloc include/linux/slab.h:741 [inline]
 kvm_vm_ioctl_register_coalesced_mmio+0xe8/0x4f0 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:147
 kvm_vm_ioctl+0x594/0x1d60 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3014
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:501 [inline]
 do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
 ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
 __do_sys_ioctl fs/ioctl.c:709 [inline]
 __se_sys_ioctl fs/ioctl.c:707 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 5583:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xcf/0x230 mm/slab.c:3817
 coalesced_mmio_destructor+0x1ad/0x2a0 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:99
 kvm_iodevice_destructor include/kvm/iodev.h:73 [inline]
 kvm_vm_ioctl_unregister_coalesced_mmio+0x263/0x330 arch/x86/kvm/../../../virt/kvm/coalesced_mmio.c:184
 kvm_vm_ioctl+0x6bc/0x1d60 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3023
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:501 [inline]
 do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
 ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
 __do_sys_ioctl fs/ioctl.c:709 [inline]
 __se_sys_ioctl fs/ioctl.c:707 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8801cd479900
 which belongs to the cache kmalloc-64 of size 64
The buggy address is located 16 bytes inside of
 64-byte region [ffff8801cd479900, ffff8801cd479940)
The buggy address belongs to the page:
page:ffffea0007351e40 count:1 mapcount:0 mapping:ffff8801da800340 index:0x0
flags: 0x2fffc0000000200(slab)
raw: 02fffc0000000200 ffffea000736b488 ffffea000736d808 ffff8801da800340
raw: 0000000000000000 ffff8801cd479000 0000000100000020 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801cd479800: 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc
 ffff8801cd479880: 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc
>ffff8801cd479900: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                         ^
 ffff8801cd479980: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
 ffff8801cd479a00: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
==================================================================

Crashes (143):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/10/19 18:30 linux-next 8c60c36d0b8c 9aba67b5 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2018/12/19 06:48 upstream ddfbab46539f 4edaba93 .config console log report ci-upstream-kasan-gce-smack-root
2018/12/19 02:55 upstream ddfbab46539f 4edaba93 .config console log report ci-upstream-kasan-gce-selinux-root
2018/12/19 01:10 upstream ddfbab46539f 4edaba93 .config console log report ci-upstream-kasan-gce-root
2018/12/17 12:36 upstream 7566ec393f41 def91db3 .config console log report ci-upstream-kasan-gce-smack-root
2018/12/17 10:24 upstream 7566ec393f41 def91db3 .config console log report ci-upstream-kasan-gce-smack-root
2018/12/17 08:26 upstream 7566ec393f41 def91db3 .config console log report ci-upstream-kasan-gce-selinux-root
2018/12/17 00:15 upstream 6531e115b7ab def91db3 .config console log report ci-upstream-kasan-gce-selinux-root
2018/12/16 11:48 upstream 6531e115b7ab def91db3 .config console log report ci-upstream-kasan-gce-smack-root
2018/12/16 03:47 upstream 6531e115b7ab def91db3 .config console log report ci-upstream-kasan-gce
2018/12/15 11:00 upstream 6531e115b7ab c9128939 .config console log report ci-upstream-kasan-gce-root
2018/12/13 01:49 upstream f5d582777bcb 02613a41 .config console log report ci-upstream-kasan-gce-selinux-root
2018/12/10 15:27 upstream 40e020c129cf 6565f24d .config console log report ci-upstream-kasan-gce-root
2018/12/10 10:06 upstream 0844895a2e51 96cc4c50 .config console log report ci-upstream-kasan-gce-smack-root
2018/12/09 18:58 upstream 8214bdf7d3e6 979179d6 .config console log report ci-upstream-kasan-gce
2018/12/09 17:09 upstream 8214bdf7d3e6 979179d6 .config console log report ci-upstream-kasan-gce
2018/12/09 07:31 upstream 8214bdf7d3e6 c7918378 .config console log report ci-upstream-kasan-gce-smack-root
2018/12/09 03:53 upstream 8214bdf7d3e6 c7918378 .config console log report ci-upstream-kasan-gce
2018/12/08 15:47 upstream 5f179793f0a7 60562a1d .config console log report ci-upstream-kasan-gce
2018/12/08 07:03 upstream 5f179793f0a7 65ed2472 .config console log report ci-upstream-kasan-gce-root
2018/12/07 20:16 upstream b72f711a4efa 1eb6a7e4 .config console log report ci-upstream-kasan-gce
2018/12/07 16:32 upstream b72f711a4efa 1eb6a7e4 .config console log report ci-upstream-kasan-gce-smack-root
2018/12/07 10:06 upstream abb8d6ecbd8f dcf836b1 .config console log report ci-upstream-kasan-gce-root
2018/12/07 01:03 upstream abb8d6ecbd8f dcf836b1 .config console log report ci-upstream-kasan-gce-selinux-root
2018/12/04 16:09 upstream 0072a0c14d5b 6ad0ae61 .config console log report ci-upstream-kasan-gce-root
2018/12/03 14:13 upstream 2595646791c3 819002b0 .config console log report ci-upstream-kasan-gce-root
2018/12/03 04:24 upstream 6a512726090a 7dcaeaf3 .config console log report ci-upstream-kasan-gce-selinux-root
2018/12/01 18:35 upstream d8f190ee836a 5a581673 .config console log report ci-upstream-kasan-gce
2018/12/01 06:47 upstream b6839ef26e54 d8988561 .config console log report ci-upstream-kasan-gce-root
2018/11/30 15:56 upstream 94f371cb7394 ade12e91 .config console log report ci-upstream-kasan-gce-selinux-root
2018/11/30 10:13 upstream f92a2ebb3d55 66071e27 .config console log report ci-upstream-kasan-gce
2018/11/30 06:01 upstream f92a2ebb3d55 66071e27 .config console log report ci-upstream-kasan-gce
2018/11/29 16:14 upstream 60b548237fed 4b6d14f2 .config console log report ci-upstream-kasan-gce-smack-root
2018/11/29 14:56 upstream 60b548237fed 4b6d14f2 .config console log report ci-upstream-kasan-gce-root
2018/11/28 01:22 upstream ef78e5ec9214 4b6d14f2 .config console log report ci-upstream-kasan-gce-root
2018/11/27 02:12 upstream 6f8b52ba442c ac912200 .config console log report ci-upstream-kasan-gce-smack-root
2018/11/26 20:54 upstream 2e6e902d1850 ac912200 .config console log report ci-upstream-kasan-gce-smack-root
2018/11/26 14:27 upstream 2e6e902d1850 ac912200 .config console log report ci-upstream-kasan-gce
2018/11/26 02:31 upstream d6d460b89378 3d3ec907 .config console log report ci-upstream-kasan-gce-smack-root
2018/11/25 14:29 upstream e195ca6cb6f2 3d3ec907 .config console log report ci-upstream-kasan-gce-selinux-root
2018/11/25 14:27 upstream e195ca6cb6f2 3d3ec907 .config console log report ci-upstream-kasan-gce-smack-root
2018/12/19 17:08 upstream 62393dbcbe0f fe2dc057 .config console log report ci-upstream-kasan-gce-386
2018/12/10 04:37 upstream 0844895a2e51 96cc4c50 .config console log report ci-upstream-kasan-gce-386
2018/11/27 09:09 upstream 6f8b52ba442c ac912200 .config console log report ci-upstream-kasan-gce-386
2018/12/16 15:46 linux-next d14b746c6c1c def91db3 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/12/14 14:11 linux-next d14b746c6c1c 7624ddd6 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/12/09 07:37 linux-next 74c4a24df7ca c7918378 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/12/02 15:37 linux-next 442b8cea2477 e0d8c853 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/12/01 06:45 linux-next 442b8cea2477 d8988561 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/10/19 16:47 linux-next 8c60c36d0b8c 9aba67b5 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.