public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: syzbot <syzbot+82112403ace4cbd780d8@syzkaller.appspotmail.com>
Cc: bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com,
	jmattson@google.com, joro@8bytes.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org, mingo@redhat.com,
	pbonzini@redhat.com, syzkaller-bugs@googlegroups.com,
	tglx@linutronix.de, vkuznets@redhat.com, wanpengli@tencent.com,
	x86@kernel.org
Subject: Re: [syzbot] WARNING in vmx_queue_exception
Date: Tue, 28 Dec 2021 20:53:49 +0000	[thread overview]
Message-ID: <Yct5XTxo/E10r5hW@google.com> (raw)
In-Reply-To: <0000000000008a5baf05d3fb593e@google.com>

On Sat, Dec 25, 2021, syzbot wrote:
> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    6e0567b73052 Merge tag 'for-linus' of git://git.kernel.org..
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=128c1adbb00000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=6104739ac5f067ea
> dashboard link: https://syzkaller.appspot.com/bug?extid=82112403ace4cbd780d8
> compiler:       Debian clang version 11.0.1-2, 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+82112403ace4cbd780d8@syzkaller.appspotmail.com
> 
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 28019 at arch/x86/kvm/vmx/vmx.c:1616 vmx_queue_exception+0x2f2/0x440 arch/x86/kvm/vmx/vmx.c:1616
> Modules linked in:
> CPU: 1 PID: 28019 Comm: syz-executor.5 Not tainted 5.16.0-rc6-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> RIP: 0010:vmx_queue_exception+0x2f2/0x440 arch/x86/kvm/vmx/vmx.c:1616
> Code: 41 5e 41 5f 5d e9 de b3 fd ff e8 79 22 60 00 eb 05 e8 72 22 60 00 48 83 c4 18 5b 41 5c 41 5d 41 5e 41 5f 5d c3 e8 5e 22 60 00 <0f> 0b e9 78 fe ff ff 89 f9 80 e1 07 38 c1 0f 8c 35 fd ff ff e8 15
> RSP: 0018:ffffc90010587450 EFLAGS: 00010287
> RAX: ffffffff812469b2 RBX: 0000000000000001 RCX: 0000000000040000
> RDX: ffffc900051ea000 RSI: 0000000000001923 RDI: 0000000000001924
> RBP: 0000000000000000 R08: ffffffff81246824 R09: ffffed100645904d
> R10: ffffed100645904d R11: 0000000000000000 R12: ffff8880322c8000
> R13: dffffc0000000000 R14: 0000000000000006 R15: 0000000080000006
> FS:  00007fe6788f8700(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007f4f4bcd8058 CR3: 0000000087d66000 CR4: 00000000003526f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
>  <TASK>
>  kvm_inject_exception arch/x86/kvm/x86.c:9071 [inline]
>  inject_pending_event arch/x86/kvm/x86.c:9145 [inline]
>  vcpu_enter_guest+0x19aa/0x9df0 arch/x86/kvm/x86.c:9801
>  vcpu_run+0x4d3/0xe50 arch/x86/kvm/x86.c:10055
>  kvm_arch_vcpu_ioctl_run+0x494/0xb20 arch/x86/kvm/x86.c:10250
>  kvm_vcpu_ioctl+0x894/0xe20 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3727
>  vfs_ioctl fs/ioctl.c:51 [inline]
>  __do_sys_ioctl fs/ioctl.c:874 [inline]
>  __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:860
>  do_syscall_x64 arch/x86/entry/common.c:50 [inline]
>  do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
>  entry_SYSCALL_64_after_hwframe+0x44/0xae

This is all but guaranteed to be "fixed" by commit cd0e615c49e5 ("KVM: nVMX:
Synthesize TRIPLE_FAULT for L2 if emulation is required").  The GCE instance has
unrestricted guest enabled, which means the only way for emulation_required to be
set is by disabling it in vmcs12.  That's also supported by the fact that this
just recently showed up, as commit c8607e4a086f ("KVM: x86: nVMX: don't fail
nested VM entry on invalid guest state if !from_vmentry") likely allowed syzkaller
to get emulation_required set while L2 is active.

But, "fixed" is in quotes because is that only covers the nested case, there are
a multitude of ways that userspace can trigger the WARN when running non-nested
with kvm_intel.unrestricted_guest=0.  The easiest "fix" would be to simply delete
the WARN.  The downside is that instead of getting a WARN or explicit error, the
vCPU will go into the weeds if userspace or KVM screws up.

The alternative is to add a pre-check in KVM_RUN to detect userspace abuse/bugs,
which would allow KVM to keep the WARN to detect KVM bugs.  A check in KVM_RUN is
necessary because KVM can't force specific ordering between KVM_SET_VCPU_EVENTS
and KVM_SET_SREGS, e.g. clearing exception.pending in KVM_SET_SREGS doesn't prevent
userspace from setting it in KVM_SET_VCPU_EVENTS, and disallowing KVM_SET_VCPU_EVENTS
with emulation_required would prevent userspace from queuing an exception and then
stuffing sregs.

I'll send a patch and test for the clean fix, it's not really gross, just annoying
that unrestricted_guest=0 requires so much dedicated handling :-/

      reply	other threads:[~2021-12-28 20:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-25 16:56 [syzbot] WARNING in vmx_queue_exception syzbot
2021-12-28 20:53 ` Sean Christopherson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yct5XTxo/E10r5hW@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=syzbot+82112403ace4cbd780d8@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox