From: Sean Christopherson <seanjc@google.com>
To: Tharit Tangkijwanichakul <tharitt97@gmail.com>
Cc: pbonzini@redhat.com, tglx@kernel.org, mingo@redhat.com,
bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
shuah@kernel.org, hpa@zytor.com, binbin.wu@linux.intel.com,
kai.huang@intel.com, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel-mentees@lists.linux.dev, skhan@linuxfoundation.org,
me@brighamcampbell.com, jkoolstra@xs4all.nl
Subject: Re: [PATCH v1 1/2] KVM: x86: Reject reserved CR8 bits in KVM_SET_SREGS
Date: Wed, 9 Sep 2026 17:27:23 -0700 [thread overview]
Message-ID: <aqH5azSkQJVXg3ef@google.com> (raw)
In-Reply-To: <20260908160426.6547-2-tharitt97@gmail.com>
On Tue, Sep 08, 2026, Tharit Tangkijwanichakul wrote:
> kvm_is_valid_sregs() validates the incoming CR0, CR4, and efer values but
> never checks CR8.
>
> When userspace passes a CR8 value with any of the
> reserved bits [63:4] set, __set_sregs_common() forwards it to
> kvm_set_cr8(), which rejects the reserved bits and returns early. That
> return value is not checked, so the ioctl reports success while the
> requested value is silently dropped. A subsequent KVM_GET_SREGS then
> returns a CR8 different from the one userspace believed it had written.
>
> Factor the reserved-bit check out into kvm_is_valid_cr8() and use it both
> in kvm_set_cr8() and in kvm_is_valid_sregs().
>
> Fixes: 2f5bb3fe5835 ("KVM: x86: Move the bulk of register specific code from x86.c to regs.c")
Heh, this goes back much further than just moving code around, all the way to:
6aa8b732ca01 ("[PATCH] kvm: userspace interface")
which did this in kvm_vcpu_ioctl_set_sregs():
6aa8b732ca01 (Avi Kivity 2006-12-10 02:21:36 -0800 2109) vcpu->cr8 = sregs->cr8;
I suppose one could argue that:
Fixes: 7017fc3d1a12 ("KVM: Define and use cr8 access functions")
is more appropriate, since this specific behavior was introduced then. I'll
probably just shove both in there and massage the changelog to explain the history.
No need for a v2, I'll fixup when applying. Thanks!
next prev parent reply other threads:[~2026-09-10 0:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 16:04 [PATCH v1 0/2] KVM: x86: cr8 reserved bit check Tharit Tangkijwanichakul
2026-09-08 16:04 ` [PATCH v1 1/2] KVM: x86: Reject reserved CR8 bits in KVM_SET_SREGS Tharit Tangkijwanichakul
2026-09-10 0:27 ` Sean Christopherson [this message]
2026-09-08 16:04 ` [PATCH v1 2/2] KVM: selftests: Add CR8 reserved-bit checks to set_sregs_test Tharit Tangkijwanichakul
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=aqH5azSkQJVXg3ef@google.com \
--to=seanjc@google.com \
--cc=binbin.wu@linux.intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jkoolstra@xs4all.nl \
--cc=kai.huang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=me@brighamcampbell.com \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=tglx@kernel.org \
--cc=tharitt97@gmail.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 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.