syzbot


KASAN: slab-out-of-bounds Read in __kvm_gfn_to_hva_cache_init

Status: fixed on 2020/06/18 13:57
Subsystems: kvm
[Documentation on labels]
Reported-by: syzbot+d889b59b2bb87d4047a2@syzkaller.appspotmail.com
Fix commit: b6467ab142b7 KVM: Check validity of resolved slot when searching memslots
First crash: 1471d, last: 1422d
Cause bisection: introduced by (bisect log) :
commit 36947254e5f981aeeedab1c7dfa35fc34d330e80
Author: Sean Christopherson <sean.j.christopherson@intel.com>
Date: Tue Feb 18 21:07:32 2020 +0000

  KVM: Dynamically size memslot array based on number of used slots

Crash: KASAN: slab-out-of-bounds Read in __kvm_gfn_to_hva_cache_init (log)
Repro: C syz .config
  
Duplicate bugs (6)
duplicates (6):
Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
KASAN: slab-out-of-bounds Read in gfn_to_memslot kvm C done 7 1453d 1461d 0/26 closed as dup on 2020/04/14 03:20
KASAN: slab-out-of-bounds Read in kvm_vcpu_gfn_to_memslot kvm C done 24153 1422d 1467d 0/26 closed as dup on 2020/04/08 01:09
KASAN: slab-out-of-bounds Read in kvm_read_guest_page kvm C done 9 1439d 1467d 0/26 closed as dup on 2020/04/08 01:08
KASAN: slab-out-of-bounds Read in gfn_to_pfn kvm 7 1449d 1464d 0/26 closed as dup on 2020/04/10 17:50
KASAN: slab-out-of-bounds Read in __kvm_map_gfn kvm C done 9 1431d 1467d 0/26 closed as dup on 2020/04/08 01:08
KASAN: slab-out-of-bounds Read in gfn_to_hva kvm C done 29 1426d 1464d 0/26 closed as dup on 2020/04/10 17:54
Discussions (8)
Title Replies (including bot) Last reply
[PATCH 4.4 00/70] 4.4.221-rc1 review 74 (74) 2020/05/02 23:27
[PATCH 4.9 00/80] 4.9.221-rc1 review 85 (85) 2020/05/02 23:18
[PATCH 4.14 000/117] 4.14.178-rc1 review 123 (123) 2020/05/02 23:17
[PATCH 5.6 000/167] 5.6.8-rc1 review 176 (176) 2020/04/30 06:41
[PATCH 5.4 000/168] 5.4.36-rc1 review 173 (173) 2020/04/29 14:05
[PATCH 4.19 000/131] 4.19.119-rc1 review 136 (136) 2020/04/29 14:04
[PATCH 0/2] KVM: Fix out-of-bounds memslot access 14 (14) 2020/04/08 14:23
KASAN: slab-out-of-bounds Read in __kvm_gfn_to_hva_cache_init 0 (1) 2020/04/07 20:06

Sample crash report:
IPVS: ftp: loaded support on port[0] = 21
L1TF CPU bug present and SMT on, data leak possible. See CVE-2018-3646 and https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/l1tf.html for details.
==================================================================
BUG: KASAN: slab-out-of-bounds in search_memslots include/linux/kvm_host.h:1051 [inline]
BUG: KASAN: slab-out-of-bounds in __gfn_to_memslot include/linux/kvm_host.h:1063 [inline]
BUG: KASAN: slab-out-of-bounds in __kvm_gfn_to_hva_cache_init+0x5fb/0x670 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2443
Read of size 8 at addr ffff88809f030468 by task syz-executor072/7032

CPU: 0 PID: 7032 Comm: syz-executor072 Not tainted 5.7.0-rc1-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+0x188/0x20d lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd3/0x315 mm/kasan/report.c:382
 __kasan_report.cold+0x35/0x4d mm/kasan/report.c:511
 kasan_report+0x33/0x50 mm/kasan/common.c:625
 search_memslots include/linux/kvm_host.h:1051 [inline]
 __gfn_to_memslot include/linux/kvm_host.h:1063 [inline]
 __kvm_gfn_to_hva_cache_init+0x5fb/0x670 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2443
 kvm_lapic_set_vapic_addr+0x88/0x180 arch/x86/kvm/lapic.c:2662
 kvm_arch_vcpu_ioctl+0xf0d/0x2c20 arch/x86/kvm/x86.c:4386
 kvm_vcpu_ioctl+0x866/0xe60 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3291
 vfs_ioctl fs/ioctl.c:47 [inline]
 ksys_ioctl+0x11a/0x180 fs/ioctl.c:763
 __do_sys_ioctl fs/ioctl.c:772 [inline]
 __se_sys_ioctl fs/ioctl.c:770 [inline]
 __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:770
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x440ac9
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 7b 10 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffe5f502ad8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000004a22b0 RCX: 0000000000440ac9
RDX: 0000000020000080 RSI: 000000004008ae93 RDI: 0000000000000005
RBP: 00007ffe5f502ae0 R08: 0000000120080522 R09: 0000000120080522
R10: 0000000120080522 R11: 0000000000000246 R12: 00000000004a22b0
R13: 0000000000402060 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 7032:
 save_stack+0x1b/0x40 mm/kasan/common.c:49
 set_track mm/kasan/common.c:57 [inline]
 __kasan_kmalloc mm/kasan/common.c:495 [inline]
 __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:468
 kmalloc_node include/linux/slab.h:578 [inline]
 kvmalloc_node+0x61/0xf0 mm/util.c:574
 kvmalloc include/linux/mm.h:757 [inline]
 kvzalloc include/linux/mm.h:765 [inline]
 kvm_dup_memslots arch/x86/kvm/../../../virt/kvm/kvm_main.c:1101 [inline]
 kvm_set_memslot+0x115/0x1530 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1118
 __kvm_set_memory_region+0xcf7/0x1320 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1300
 __x86_set_memory_region+0x2a3/0x5a0 arch/x86/kvm/x86.c:9856
 alloc_apic_access_page arch/x86/kvm/vmx/vmx.c:3540 [inline]
 vmx_create_vcpu+0x2107/0x2b40 arch/x86/kvm/vmx/vmx.c:6799
 kvm_arch_vcpu_create+0x6ef/0xb80 arch/x86/kvm/x86.c:9376
 kvm_vm_ioctl_create_vcpu arch/x86/kvm/../../../virt/kvm/kvm_main.c:3030 [inline]
 kvm_vm_ioctl+0x15f7/0x23e0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3585
 vfs_ioctl fs/ioctl.c:47 [inline]
 ksys_ioctl+0x11a/0x180 fs/ioctl.c:763
 __do_sys_ioctl fs/ioctl.c:772 [inline]
 __se_sys_ioctl fs/ioctl.c:770 [inline]
 __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:770
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3

Freed by task 0:
(stack is not available)

The buggy address belongs to the object at ffff88809f030000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1128 bytes inside of
 2048-byte region [ffff88809f030000, ffff88809f030800)
The buggy address belongs to the page:
page:ffffea00027c0c00 refcount:1 mapcount:0 mapping:0000000058c93d70 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea0002694008 ffffea00029e98c8 ffff8880aa000e00
raw: 0000000000000000 ffff88809f030000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809f030300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88809f030380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88809f030400: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc
                                                          ^
 ffff88809f030480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88809f030500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (1537):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/04/17 09:59 upstream 7a56db0299f9 18397578 .config console log report syz C ci-upstream-kasan-gce
2020/04/17 09:06 upstream 7a56db0299f9 18397578 .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/11 04:21 upstream ab6f762f0f53 a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/09 14:51 upstream ae46d2aa6a7f a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce
2020/04/09 13:04 upstream ae46d2aa6a7f a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce
2020/04/03 15:41 upstream bef7b2a7be28 5ed396e6 .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/03 13:09 upstream bef7b2a7be28 5ed396e6 .config console log report syz C ci-upstream-kasan-gce
2020/04/19 07:14 upstream 50cc09c18985 365fba24 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/15 22:15 upstream 8632e9b5645b 3f3c5574 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/12 10:41 upstream b032227c6293 a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/12 08:58 upstream b032227c6293 a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/12 03:48 upstream 5b8b9d0c6d0e a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce-386
2020/05/07 02:46 linux-next ac935d227366 4618eb2d .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/04/29 01:00 linux-next ac935d227366 e3ecea2e .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/04/28 23:10 linux-next ac935d227366 e3ecea2e .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/04/28 19:50 linux-next ac935d227366 e3ecea2e .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/04/03 15:04 upstream bef7b2a7be28 5ed396e6 .config console log report syz ci-upstream-kasan-gce-selinux-root
2020/04/22 12:18 upstream 189522da8b3a 2e44d63e .config console log report ci-upstream-kasan-gce
2020/04/22 06:57 upstream 189522da8b3a 2e44d63e .config console log report ci-upstream-kasan-gce-smack-root
2020/04/21 23:13 upstream 189522da8b3a 2e44d63e .config console log report ci-upstream-kasan-gce-selinux-root
2020/04/21 22:03 upstream 189522da8b3a 2e44d63e .config console log report ci-upstream-kasan-gce-root
2020/04/03 11:16 upstream bef7b2a7be28 5ed396e6 .config console log report ci-upstream-kasan-gce
2020/04/22 11:16 upstream 189522da8b3a 2e44d63e .config console log report ci-upstream-kasan-gce-386
2020/05/22 12:19 linux-next ac935d227366 5afa2ddd .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/22 11:06 linux-next ac935d227366 5afa2ddd .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/22 09:58 linux-next ac935d227366 5afa2ddd .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/22 05:23 linux-next ac935d227366 5afa2ddd .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/22 00:34 linux-next ac935d227366 1f30020f .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/21 21:26 linux-next ac935d227366 1f30020f .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/21 20:07 linux-next ac935d227366 1f30020f .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/21 17:24 linux-next ac935d227366 1f30020f .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/21 16:54 linux-next ac935d227366 1f30020f .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/21 13:29 linux-next ac935d227366 1f30020f .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/21 10:27 linux-next ac935d227366 c61086ab .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/21 08:51 linux-next ac935d227366 c61086ab .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/20 22:55 linux-next ac935d227366 1255f02a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/20 20:32 linux-next ac935d227366 1255f02a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/20 17:29 linux-next ac935d227366 1255f02a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/20 16:28 linux-next ac935d227366 1255f02a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/20 13:49 linux-next ac935d227366 1255f02a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/20 10:18 linux-next ac935d227366 67fa1f59 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/20 08:19 linux-next ac935d227366 67fa1f59 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/20 04:53 linux-next ac935d227366 67fa1f59 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/20 01:25 linux-next ac935d227366 67fa1f59 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/19 20:37 linux-next ac935d227366 6d882fd2 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/19 18:28 linux-next ac935d227366 6d882fd2 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/19 14:54 linux-next ac935d227366 6d882fd2 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/19 09:59 linux-next ac935d227366 684d3606 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/19 05:35 linux-next ac935d227366 684d3606 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/19 03:39 linux-next ac935d227366 684d3606 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/18 18:55 linux-next ac935d227366 684d3606 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/18 17:58 linux-next ac935d227366 684d3606 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/18 11:35 linux-next ac935d227366 37bccd4e .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/18 10:15 linux-next ac935d227366 37bccd4e .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/18 08:46 linux-next ac935d227366 37bccd4e .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/18 07:39 linux-next ac935d227366 37bccd4e .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/18 05:18 linux-next ac935d227366 37bccd4e .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/18 03:04 linux-next ac935d227366 37bccd4e .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/18 01:43 linux-next ac935d227366 37bccd4e .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/17 23:40 linux-next ac935d227366 37bccd4e .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/17 05:05 linux-next ac935d227366 37bccd4e .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/17 00:58 linux-next ac935d227366 37bccd4e .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/16 21:52 linux-next ac935d227366 37bccd4e .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/16 10:21 linux-next ac935d227366 37bccd4e .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/16 08:26 linux-next ac935d227366 37bccd4e .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/16 02:59 linux-next ac935d227366 37bccd4e .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.