From: sashiko-bot@kernel.org
To: "Deepanshu Kartikey" <kartikey406@gmail.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: x86: Handle -1 return from kvm_cpu_get_interrupt
Date: Sun, 12 Jul 2026 09:11:07 +0000 [thread overview]
Message-ID: <20260712091108.903141F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260712090039.36038-1-kartikey406@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The patch introduces a control flow bypass regression. By replacing `WARN_ON_ONCE(irq == -1)` with an early `goto out;`, the function `kvm_check_and_inject_events()` prematurely aborts. This inadvertently skips the critical trailing check for nested events, potentially breaking nested virtualization.
--
--- Patch [1]: [PATCH] KVM: x86: Handle -1 return from kvm_cpu_get_interrupt ---
commit 5f633807782c397266e8aeeaaf39fb310a7b09ee
Author: Deepanshu Kartikey <kartikey406@gmail.com>
KVM: x86: Handle -1 return from kvm_cpu_get_interrupt
This commit modifies kvm_check_and_inject_events() to gracefully handle a
valid race condition where kvm_cpu_get_interrupt() returns -1. It replaces
a WARN_ON_ONCE with an early goto out to handle situations where another
thread has already consumed the interrupt.
Link: https://syzkaller.appspot.com/bug?extid=9dcd0a11dc9703a49511
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index ff8812f3a1293..ec449e9a3f954 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -10765,11 +10765,11 @@ static int kvm_check_and_inject_events(struct kvm_vcpu *vcpu,
> if (r) {
> int irq = kvm_cpu_get_interrupt(vcpu);
>
> - if (!WARN_ON_ONCE(irq == -1)) {
> - kvm_queue_interrupt(vcpu, irq, false);
> - kvm_x86_call(inject_irq)(vcpu, false);
> - WARN_ON(kvm_x86_call(interrupt_allowed)(vcpu, true) < 0);
> - }
> + if (irq == -1)
> + goto out;
[Severity: High]
Does this early goto out prematurely skip the remaining checks in
kvm_check_and_inject_events()?
By jumping directly to out, the code skips the enable_irq_window() call and
the trailing nested event evaluation block:
if (is_guest_mode(vcpu) &&
kvm_x86_ops.nested_ops->has_events &&
kvm_x86_ops.nested_ops->has_events(vcpu, true))
*req_immediate_exit = true;
When a concurrently consumed PIC interrupt results in irq == -1, wouldn't
bypassing this logic prevent KVM from setting req_immediate_exit when
required, potentially causing the vCPU to incorrectly continue executing L2
guest code instead of exiting to L1?
> + kvm_queue_interrupt(vcpu, irq, false);
> + kvm_x86_call(inject_irq)(vcpu, false);
> + WARN_ON(kvm_x86_call(interrupt_allowed)(vcpu, true) < 0);
> }
> if (kvm_cpu_has_injectable_intr(vcpu))
> kvm_x86_call(enable_irq_window)(vcpu);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260712090039.36038-1-kartikey406@gmail.com?part=1
prev parent reply other threads:[~2026-07-12 9:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-12 9:00 [PATCH] KVM: x86: Handle -1 return from kvm_cpu_get_interrupt Deepanshu Kartikey
2026-07-12 9:11 ` sashiko-bot [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=20260712091108.903141F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kartikey406@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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