syzbot


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

Status: closed as dup on 2020/04/08 01:08
Subsystems: kvm
[Documentation on labels]
Reported-by: syzbot+a65b3f8eec6b27650a25@syzkaller.appspotmail.com
First crash: 1431d, last: 1399d
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_read_guest_page (log)
Repro: C syz .config
  
Duplicate of
Title Repro Cause bisect Fix bisect Count Last Reported
KASAN: slab-out-of-bounds Read in __kvm_gfn_to_hva_cache_init kvm C done 1537 1382d 1426d
Discussions (1)
Title Replies (including bot) Last reply
KASAN: slab-out-of-bounds Read in kvm_read_guest_page 1 (2) 2020/04/08 01:08

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/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 gfn_to_memslot arch/x86/kvm/../../../virt/kvm/kvm_main.c:1597 [inline]
BUG: KASAN: slab-out-of-bounds in kvm_read_guest_page+0x4b5/0x4d0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2261
Read of size 8 at addr ffff8880a6f4c468 by task syz-executor664/7134

CPU: 1 PID: 7134 Comm: syz-executor664 Not tainted 5.6.0-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]
 gfn_to_memslot arch/x86/kvm/../../../virt/kvm/kvm_main.c:1597 [inline]
 kvm_read_guest_page+0x4b5/0x4d0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2261
 kvm_read_guest+0x51/0xd0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2284
 kvm_write_wall_clock arch/x86/kvm/x86.c:1721 [inline]
 kvm_set_msr_common+0xdf3/0x27c0 arch/x86/kvm/x86.c:2851
 vmx_set_msr+0xa83/0x26a0 arch/x86/kvm/vmx/vmx.c:2183
 __kvm_set_msr+0x15f/0x2d0 arch/x86/kvm/x86.c:1504
 __msr_io arch/x86/kvm/x86.c:3262 [inline]
 msr_io+0x173/0x290 arch/x86/kvm/x86.c:3298
 kvm_arch_vcpu_ioctl+0x1004/0x2c20 arch/x86/kvm/x86.c:4355
 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:0x440439
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 fb 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fffc1a95fa8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 0000000000440439
RDX: 0000000020000100 RSI: 000000004008ae89 RDI: 0000000000000005
RBP: 00000000006ca018 R08: 00000000004002c8 R09: 00000000004002c8
R10: 00000000004002c8 R11: 0000000000000246 R12: 0000000000401cc0
R13: 0000000000401d50 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 7134:
 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:739 [inline]
 kvzalloc include/linux/mm.h:747 [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
 kvm_set_memory_region+0x29/0x50 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1321
 kvm_vm_ioctl_set_memory_region arch/x86/kvm/../../../virt/kvm/kvm_main.c:1333 [inline]
 kvm_vm_ioctl+0x678/0x23e0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3604
 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 ffff8880a6f4c000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1128 bytes inside of
 2048-byte region [ffff8880a6f4c000, ffff8880a6f4c800)
The buggy address belongs to the page:
page:ffffea00029bd300 refcount:1 mapcount:0 mapping:00000000b535bfac index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea00029abe08 ffffea00027feec8 ffff8880aa000e00
raw: 0000000000000000 ffff8880a6f4c000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a6f4c300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880a6f4c380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8880a6f4c400: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc
                                                          ^
 ffff8880a6f4c480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880a6f4c500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (9):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/04/09 10:37 upstream ae46d2aa6a7f a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce
2020/04/03 14:54 upstream bef7b2a7be28 5ed396e6 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/28 22:12 linux-next ac935d227366 e3ecea2e .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/04/03 12:58 upstream bef7b2a7be28 5ed396e6 .config console log report ci-upstream-kasan-gce-386
2020/04/03 11:26 upstream bef7b2a7be28 5ed396e6 .config console log report ci-upstream-kasan-gce-386
2020/05/05 06:21 linux-next ac935d227366 9941337c .config console log report ci-upstream-linux-next-kasan-gce-root
2020/04/26 04:59 linux-next ac935d227366 99b258dd .config console log report ci-upstream-linux-next-kasan-gce-root
2020/04/24 22:01 linux-next ac935d227366 03d97a1b .config console log report ci-upstream-linux-next-kasan-gce-root
2020/04/24 21:50 linux-next ac935d227366 03d97a1b .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.