All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Binbin Wu" <binbin.wu@linux.intel.com>
Cc: kvm@vger.kernel.org
Subject: Re: [RFC PATCH v2 3/4] KVM: x86: TDX: Validate userspace CPUID input for KVM_TDX_INIT_VM
Date: Thu, 04 Jun 2026 02:49:27 +0000	[thread overview]
Message-ID: <20260604024927.E22311F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260604023314.3907511-4-binbin.wu@linux.intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] `tdx_unsupported_cpuid()` incorrectly uses the userspace-provided CPUID index instead of the canonical TDX configurable index for validation, allowing feature allowlist bypasses.
--

commit c2adba56353483cd6dcf40b3fe14141409c0ce54
Author: Binbin Wu <binbin.wu@linux.intel.com>

KVM: x86: TDX: Validate userspace CPUID input for KVM_TDX_INIT_VM

This commit replaces the hardcoded CPUID denylist with a validation mechanism
that checks userspace input against KVM's supported allowlist. It aims to
prevent userspace from enabling unsupported TDX features during VM init.

> diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> --- a/arch/x86/kvm/vmx/tdx.c
> +++ b/arch/x86/kvm/vmx/tdx.c
[ ... ]
> +static bool tdx_unsupported_cpuid(const struct kvm_cpuid_entry2 *e,
> +				  const struct kvm_cpuid_entry2 *mask)
> +{
> +	return ((e->eax & mask->eax & (~get_supported_cfg_cpuid(e->function, e->index, CPUID_EAX))) ||
> +		(e->ebx & mask->ebx & (~get_supported_cfg_cpuid(e->function, e->index, CPUID_EBX))) ||
> +		(e->ecx & mask->ecx & (~get_supported_cfg_cpuid(e->function, e->index, CPUID_ECX))) ||
> +		(e->edx & mask->edx & (~get_supported_cfg_cpuid(e->function, e->index, CPUID_EDX))));
> +}

[Severity: High]
Does this validation query the allowlist using the correct index?

If userspace provides a CPUID entry with the KVM_CPUID_FLAG_SIGNIFCANT_INDEX
flag cleared, kvm_find_cpuid_entry2() matches based solely on the function.
This means the returned entry 'e' could contain an arbitrary, user-controlled
index.

Because get_supported_cfg_cpuid() is queried using e->index instead of the
canonical target subleaf mask->index, userspace could spoof e->index to
point to a more permissive subleaf in KVM's allowlist. The TDX module would
then blindly apply those validated bits to the original, narrower target
subleaf, bypassing the intended feature restrictions.

Should this use mask->index instead of e->index when querying the allowlist?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260604023314.3907511-1-binbin.wu@linux.intel.com?part=3

  reply	other threads:[~2026-06-04  2:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-04  2:33 [RFC PATCH v2 0/4] KVM: x86: TDX: Validate directly configurable CPUID bits Binbin Wu
2026-06-04  2:33 ` [RFC PATCH v2 1/4] KVM: x86: TDX: Track supported " Binbin Wu
2026-06-04  2:44   ` sashiko-bot
2026-06-04  5:37     ` Binbin Wu
2026-06-04  2:33 ` [RFC PATCH v2 2/4] KVM: x86: TDX: Hide unsupported " Binbin Wu
2026-06-04  2:47   ` sashiko-bot
2026-06-04  2:54     ` Binbin Wu
2026-06-04  2:33 ` [RFC PATCH v2 3/4] KVM: x86: TDX: Validate userspace CPUID input for KVM_TDX_INIT_VM Binbin Wu
2026-06-04  2:49   ` sashiko-bot [this message]
2026-06-04  3:13     ` Binbin Wu
2026-06-04  2:33 ` [RFC PATCH v2 4/4] KVM: x86: TDX: Report CORE_CAPABILITIES as supported Binbin Wu
2026-06-04  2:51   ` sashiko-bot
2026-06-04  5:32     ` Binbin Wu
2026-06-04  5:40       ` Binbin Wu
2026-06-04  6:53   ` Xiaoyao Li
2026-06-04  7:20     ` Binbin Wu

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=20260604024927.E22311F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=binbin.wu@linux.intel.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 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.