* [syzbot] kernel BUG in kvm_read_guest_offset_cached @ 2021-11-22 22:14 syzbot 2021-11-24 11:18 ` Vitaly Kuznetsov 0 siblings, 1 reply; 3+ messages in thread From: syzbot @ 2021-11-22 22:14 UTC (permalink / raw) To: kvm, linux-kernel, pbonzini, syzkaller-bugs Hello, syzbot found the following issue on: HEAD commit: 4c388a8e740d Merge tag 'zstd-for-linus-5.16-rc1' of git://.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=171ff6eeb00000 kernel config: https://syzkaller.appspot.com/x/.config?x=6d3b8fd1977c1e73 dashboard link: https://syzkaller.appspot.com/bug?extid=7b7db8bb4db6fd5e157b compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2 Unfortunately, I don't have any reproducer for this issue yet. IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+7b7db8bb4db6fd5e157b@syzkaller.appspotmail.com ------------[ cut here ]------------ kernel BUG at arch/x86/kvm/../../../virt/kvm/kvm_main.c:2955! invalid opcode: 0000 [#1] PREEMPT SMP KASAN CPU: 0 PID: 27639 Comm: syz-executor.0 Not tainted 5.16.0-rc1-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:kvm_read_guest_offset_cached+0x3aa/0x440 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2955 Code: 00 48 c7 c2 c0 08 a2 89 be 0b 03 00 00 48 c7 c7 60 0d a2 89 c6 05 71 f9 73 0c 01 e8 62 19 f8 07 e9 d6 fc ff ff e8 36 1b 6f 00 <0f> 0b e8 2f 1b 6f 00 48 8b 74 24 10 4c 89 ef 4c 89 e1 48 8b 54 24 RSP: 0018:ffffc9000589fa18 EFLAGS: 00010216 RAX: 0000000000003b75 RBX: ffff8880722ba798 RCX: ffffc90002b94000 RDX: 0000000000040000 RSI: ffffffff81087cda RDI: 0000000000000003 RBP: 0000000000000000 R08: 0000000000000004 R09: ffffc900049dbf53 R10: ffffffff81087a0f R11: 0000000000000002 R12: 0000000000000004 R13: ffffc900049d1000 R14: 0000000000000000 R15: ffff8880886c0000 FS: 00007fd7a562f700(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020000200 CR3: 0000000038e62000 CR4: 00000000003526f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 000000000000c0fe DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Call Trace: <TASK> handle_vmptrld arch/x86/kvm/vmx/nested.c:5304 [inline] handle_vmptrld+0x39d/0x820 arch/x86/kvm/vmx/nested.c:5266 __vmx_handle_exit arch/x86/kvm/vmx/vmx.c:6012 [inline] vmx_handle_exit+0x4f7/0x18a0 arch/x86/kvm/vmx/vmx.c:6029 vcpu_enter_guest+0x2b41/0x4440 arch/x86/kvm/x86.c:9941 vcpu_run arch/x86/kvm/x86.c:10008 [inline] kvm_arch_vcpu_ioctl_run+0x4fc/0x21a0 arch/x86/kvm/x86.c:10203 kvm_vcpu_ioctl+0x570/0xf30 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3709 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:874 [inline] __se_sys_ioctl fs/ioctl.c:860 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:860 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7fd7a80b9ae9 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 bc ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fd7a562f188 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007fd7a81ccf60 RCX: 00007fd7a80b9ae9 RDX: 0000000000000000 RSI: 000000000000ae80 RDI: 0000000000000006 RBP: 00007fd7a8113f6d R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fd7a8700b2f R14: 00007fd7a562f300 R15: 0000000000022000 </TASK> Modules linked in: ---[ end trace 05ad48ac8b464d71 ]--- RIP: 0010:kvm_read_guest_offset_cached+0x3aa/0x440 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2955 Code: 00 48 c7 c2 c0 08 a2 89 be 0b 03 00 00 48 c7 c7 60 0d a2 89 c6 05 71 f9 73 0c 01 e8 62 19 f8 07 e9 d6 fc ff ff e8 36 1b 6f 00 <0f> 0b e8 2f 1b 6f 00 48 8b 74 24 10 4c 89 ef 4c 89 e1 48 8b 54 24 RSP: 0018:ffffc9000589fa18 EFLAGS: 00010216 RAX: 0000000000003b75 RBX: ffff8880722ba798 RCX: ffffc90002b94000 RDX: 0000000000040000 RSI: ffffffff81087cda RDI: 0000000000000003 RBP: 0000000000000000 R08: 0000000000000004 R09: ffffc900049dbf53 R10: ffffffff81087a0f R11: 0000000000000002 R12: 0000000000000004 R13: ffffc900049d1000 R14: 0000000000000000 R15: ffff8880886c0000 FS: 00007fd7a562f700(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f18994c5000 CR3: 0000000038e62000 CR4: 00000000003526e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000003000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [syzbot] kernel BUG in kvm_read_guest_offset_cached 2021-11-22 22:14 [syzbot] kernel BUG in kvm_read_guest_offset_cached syzbot @ 2021-11-24 11:18 ` Vitaly Kuznetsov 2021-11-24 11:25 ` Paolo Bonzini 0 siblings, 1 reply; 3+ messages in thread From: Vitaly Kuznetsov @ 2021-11-24 11:18 UTC (permalink / raw) To: pbonzini, David Woodhouse Cc: kvm, linux-kernel, syzbot, syzkaller-bugs, Sean Christopherson syzbot <syzbot+7b7db8bb4db6fd5e157b@syzkaller.appspotmail.com> writes: > Hello, > > syzbot found the following issue on: > > HEAD commit: 4c388a8e740d Merge tag 'zstd-for-linus-5.16-rc1' of git://.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=171ff6eeb00000 > kernel config: https://syzkaller.appspot.com/x/.config?x=6d3b8fd1977c1e73 > dashboard link: https://syzkaller.appspot.com/bug?extid=7b7db8bb4db6fd5e157b > compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2 > > Unfortunately, I don't have any reproducer for this issue yet. No worries, I think I do. > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > Reported-by: syzbot+7b7db8bb4db6fd5e157b@syzkaller.appspotmail.com > > ------------[ cut here ]------------ > kernel BUG at arch/x86/kvm/../../../virt/kvm/kvm_main.c:2955! > invalid opcode: 0000 [#1] PREEMPT SMP KASAN > CPU: 0 PID: 27639 Comm: syz-executor.0 Not tainted 5.16.0-rc1-syzkaller #0 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 > RIP: 0010:kvm_read_guest_offset_cached+0x3aa/0x440 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2955 > Code: 00 48 c7 c2 c0 08 a2 89 be 0b 03 00 00 48 c7 c7 60 0d a2 89 c6 05 71 f9 73 0c 01 e8 62 19 f8 07 e9 d6 fc ff ff e8 36 1b 6f 00 <0f> 0b e8 2f 1b 6f 00 48 8b 74 24 10 4c 89 ef 4c 89 e1 48 8b 54 24 > RSP: 0018:ffffc9000589fa18 EFLAGS: 00010216 > RAX: 0000000000003b75 RBX: ffff8880722ba798 RCX: ffffc90002b94000 > RDX: 0000000000040000 RSI: ffffffff81087cda RDI: 0000000000000003 > RBP: 0000000000000000 R08: 0000000000000004 R09: ffffc900049dbf53 > R10: ffffffff81087a0f R11: 0000000000000002 R12: 0000000000000004 > R13: ffffc900049d1000 R14: 0000000000000000 R15: ffff8880886c0000 > FS: 00007fd7a562f700(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000 > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > CR2: 0000000020000200 CR3: 0000000038e62000 CR4: 00000000003526f0 > DR0: 0000000000000000 DR1: 0000000000000000 DR2: 000000000000c0fe > DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 > Call Trace: > <TASK> > handle_vmptrld arch/x86/kvm/vmx/nested.c:5304 [inline] The code is: struct gfn_to_hva_cache *ghc = &vmx->nested.vmcs12_cache; struct vmcs_hdr hdr; if (ghc->gpa != vmptr && kvm_gfn_to_hva_cache_init(vcpu->kvm, ghc, vmptr, VMCS12_SIZE)) { ... } if (kvm_read_guest_offset_cached(vcpu->kvm, ghc, &hdr, offsetof(struct vmcs12, hdr), sizeof(hdr))) { .... It seems that 'nested.vmcs12_cache' is zero-initalized and 'ghc->gpa != vmptr' check will pass if VMPTRLD is called with '0' argument. The following hack to 'state_test.c' can be used to crash host's kernel: diff --git a/tools/testing/selftests/kvm/x86_64/state_test.c b/tools/testing/selftests/kvm/x86_64/state_test.c index 32854c1462ad..29b468f1a083 100644 --- a/tools/testing/selftests/kvm/x86_64/state_test.c +++ b/tools/testing/selftests/kvm/x86_64/state_test.c @@ -81,6 +81,9 @@ static void vmx_l1_guest_code(struct vmx_pages *vmx_pages) GUEST_ASSERT(vmx_pages->vmcs_gpa); GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages)); GUEST_SYNC(3); + + vmptrld(0); + GUEST_ASSERT(load_vmcs(vmx_pages)); GUEST_ASSERT(vmptrstz() == vmx_pages->vmcs_gpa); This seems to be a regression introduced by commit cee66664dcd6241a943380ef9dcd2f8a0a7dc47d Author: David Woodhouse <dwmw@amazon.co.uk> Date: Mon Nov 15 16:50:26 2021 +0000 KVM: nVMX: Use a gfn_to_hva_cache for vmptrld Luckily, it's in 5.16-rc2 only. I think the solution is to assign 'ghc->gpa' to '-1' upon initialization. I can send a patch if my conclusions seem to be right. -- Vitaly ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [syzbot] kernel BUG in kvm_read_guest_offset_cached 2021-11-24 11:18 ` Vitaly Kuznetsov @ 2021-11-24 11:25 ` Paolo Bonzini 0 siblings, 0 replies; 3+ messages in thread From: Paolo Bonzini @ 2021-11-24 11:25 UTC (permalink / raw) To: Vitaly Kuznetsov, David Woodhouse Cc: kvm, linux-kernel, syzbot, syzkaller-bugs, Sean Christopherson On 11/24/21 12:18, Vitaly Kuznetsov wrote: >> >> syzbot found the following issue on: >> >> HEAD commit: 4c388a8e740d Merge tag 'zstd-for-linus-5.16-rc1' of git://.. >> git tree: upstream >> console output:https://syzkaller.appspot.com/x/log.txt?x=171ff6eeb00000 >> kernel config:https://syzkaller.appspot.com/x/.config?x=6d3b8fd1977c1e73 >> dashboard link:https://syzkaller.appspot.com/bug?extid=7b7db8bb4db6fd5e157b >> compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2 >> >> Unfortunately, I don't have any reproducer for this issue yet. > No worries, I think I do. > FWIW I have already posted a patch. Thanks for the reproducer though! Paolo ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-24 11:25 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-11-22 22:14 [syzbot] kernel BUG in kvm_read_guest_offset_cached syzbot 2021-11-24 11:18 ` Vitaly Kuznetsov 2021-11-24 11:25 ` Paolo Bonzini
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox