From: sashiko-bot@kernel.org
To: "Yosry Ahmed" <yosry@kernel.org>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v3 2/5] KVM: x86: Disallow EFER.LME and EFER.LMA if long mode is not supported
Date: Mon, 13 Jul 2026 18:42:56 +0000 [thread overview]
Message-ID: <20260713184256.82C181F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260713181020.2735367-3-yosry@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] KVM_SET_SREGS bypasses EFER validation, permitting userspace to set unsupported EFER bits and potentially triggering a host kernel BUG_ON.
--
--- Patch [2]: [PATCH v3 2/5] KVM: x86: Disallow EFER.LME and EFER.LMA if long mode is not supported ---
commit 804513f9cd9e8710ae3f651192ce52e48ee9e59a
Author: Yosry Ahmed <yosry@kernel.org>
KVM: x86: Disallow EFER.LME and EFER.LMA if long mode is not supported
Remove EFER.LME and EFER.LMA from EFER reserved bits only if long mode
is actually supported.
> KVM does check long-mode support before allowing
> the bits for guest writes and userspace writes through KVM_SET_SREGS*
> (in __kvm_valid_efer()), but userspace writes through KVM_SET_MSRS only
> check reserved bits.
[Severity: High]
This isn't a bug introduced by this patch, but is the claim about
KVM_SET_SREGS* checking __kvm_valid_efer() accurate?
It looks like KVM_SET_SREGS can actually bypass __kvm_valid_efer(). If
userspace invokes the KVM_SET_SREGS ioctl with a crafted sregs structure
where EFER_LME=1, EFER_LMA=1, CR0.PG=1, and CR4.PAE=1, this state appears
to bypass the consistency checks in kvm_is_valid_sregs().
Then, __set_sregs_common() applies the EFER bits directly via the
architecture-specific callback:
arch/x86/kvm/regs.c:__set_sregs_common() {
...
kvm_x86_call(set_efer)(vcpu, sregs->efer);
...
}
On a 32-bit KVM host (!CONFIG_X86_64), this call reaches vmx_set_efer(),
which unconditionally triggers a KVM_BUG_ON since long mode is not
supported:
arch/x86/kvm/vmx/vmx.c:vmx_set_efer() {
...
if (KVM_BUG_ON(efer & EFER_LMA, vcpu->kvm))
return 1;
...
}
Additionally, on SVM, bypassing __kvm_valid_efer() allows userspace to set
EFER_SVME and force nested state allocation even when the guest lacks the
X86_FEATURE_SVM capability.
Could this allow a malicious unprivileged userspace process to trigger a
host kernel panic (if panic_on_warn=1) by forcing this KVM_BUG_ON?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260713181020.2735367-1-yosry@kernel.org?part=2
next prev parent reply other threads:[~2026-07-13 18:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 18:10 [PATCH v3 0/5] KVM: x86: Fix EFER reserved bits initialization Yosry Ahmed
2026-07-13 18:10 ` [PATCH v3 1/5] KVM: x86: Move enabling EFER.SVME and EFER.LMSLE to generic EFER setup Yosry Ahmed
2026-07-13 18:10 ` [PATCH v3 2/5] KVM: x86: Disallow EFER.LME and EFER.LMA if long mode is not supported Yosry Ahmed
2026-07-13 18:42 ` sashiko-bot [this message]
2026-07-13 18:50 ` Yosry Ahmed
2026-07-13 18:10 ` [PATCH v3 3/5] KVM: x86: Always initialize EFER reserved bits on vendor initialization Yosry Ahmed
2026-07-13 18:10 ` [PATCH v3 4/5] KVM: x86: Reverse the polarity of efer_reserved_bits Yosry Ahmed
2026-07-13 18:10 ` [PATCH v3 5/5] KVM: x86: Move supported EFER bits to kvm_caps Yosry Ahmed
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=20260713184256.82C181F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yosry@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.