stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Michael Kelley <mikelley@microsoft.com>,
	Wei Liu <wei.liu@kernel.org>, Sasha Levin <sashal@kernel.org>,
	kys@microsoft.com, haiyangz@microsoft.com, decui@microsoft.com,
	tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org,
	linux-hyperv@vger.kernel.org
Subject: [PATCH AUTOSEL 6.2 04/17] x86/hyperv: Block root partition functionality in a Confidential VM
Date: Thu, 20 Apr 2023 07:01:33 -0400	[thread overview]
Message-ID: <20230420110148.505779-4-sashal@kernel.org> (raw)
In-Reply-To: <20230420110148.505779-1-sashal@kernel.org>

From: Michael Kelley <mikelley@microsoft.com>

[ Upstream commit f8acb24aaf89fc46cd953229462ea8abe31b395f ]

Hyper-V should never specify a VM that is a Confidential VM and also
running in the root partition.  Nonetheless, explicitly block such a
combination to guard against a compromised Hyper-V maliciously trying to
exploit root partition functionality in a Confidential VM to expose
Confidential VM secrets. No known bug is being fixed, but the attack
surface for Confidential VMs on Hyper-V is reduced.

Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Link: https://lore.kernel.org/r/1678894453-95392-1-git-send-email-mikelley@microsoft.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/x86/kernel/cpu/mshyperv.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 46668e2554210..1ce228dc267ae 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -291,12 +291,16 @@ static void __init ms_hyperv_init_platform(void)
 	 * To mirror what Windows does we should extract CPU management
 	 * features and use the ReservedIdentityBit to detect if Linux is the
 	 * root partition. But that requires negotiating CPU management
-	 * interface (a process to be finalized).
+	 * interface (a process to be finalized). For now, use the privilege
+	 * flag as the indicator for running as root.
 	 *
-	 * For now, use the privilege flag as the indicator for running as
-	 * root.
+	 * Hyper-V should never specify running as root and as a Confidential
+	 * VM. But to protect against a compromised/malicious Hyper-V trying
+	 * to exploit root behavior to expose Confidential VM memory, ignore
+	 * the root partition setting if also a Confidential VM.
 	 */
-	if (cpuid_ebx(HYPERV_CPUID_FEATURES) & HV_CPU_MANAGEMENT) {
+	if ((ms_hyperv.priv_high & HV_CPU_MANAGEMENT) &&
+	    !(ms_hyperv.priv_high & HV_ISOLATION)) {
 		hv_root_partition = true;
 		pr_info("Hyper-V: running as root partition\n");
 	}
-- 
2.39.2


  parent reply	other threads:[~2023-04-20 11:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-20 11:01 [PATCH AUTOSEL 6.2 01/17] ASOC: Intel: sof_sdw: add quirk for Intel 'Rooks County' NUC M15 Sasha Levin
2023-04-20 11:01 ` [PATCH AUTOSEL 6.2 02/17] ASoC: Intel: soc-acpi: add table " Sasha Levin
2023-04-20 11:01 ` [PATCH AUTOSEL 6.2 03/17] ASoC: soc-pcm: fix hw->formats cleared by soc_pcm_hw_init() for dpcm Sasha Levin
2023-04-20 11:01 ` Sasha Levin [this message]
2023-04-20 11:01 ` [PATCH AUTOSEL 6.2 05/17] ASoC: amd: yc: Add DMI entries to support Victus by HP Laptop 16-e1xxx (8A22) Sasha Levin
2023-04-20 11:01 ` [PATCH AUTOSEL 6.2 06/17] iio: adc: palmas_gpadc: fix NULL dereference on rmmod Sasha Levin
2023-04-20 11:01 ` [PATCH AUTOSEL 6.2 07/17] ASoC: Intel: bytcr_rt5640: Add quirk for the Acer Iconia One 7 B1-750 Sasha Levin
2023-04-20 11:01 ` [PATCH AUTOSEL 6.2 08/17] pwm: Zero-initialize the pwm_state passed to driver's .get_state() Sasha Levin
2023-04-20 11:01 ` [PATCH AUTOSEL 6.2 09/17] ASoC: da7213.c: add missing pm_runtime_disable() Sasha Levin
2023-04-20 11:01 ` [PATCH AUTOSEL 6.2 10/17] net: wwan: t7xx: do not compile with -Werror Sasha Levin
2023-04-20 11:01 ` [PATCH AUTOSEL 6.2 11/17] wifi: mt76: mt7921: Fix use-after-free in fw features query Sasha Levin
2023-04-20 11:01 ` [PATCH AUTOSEL 6.2 12/17] selftests mount: Fix mount_setattr_test builds failed Sasha Levin
2023-04-20 11:01 ` [PATCH AUTOSEL 6.2 13/17] scsi: mpi3mr: Handle soft reset in progress fault code (0xF002) Sasha Levin
2023-04-20 11:01 ` [PATCH AUTOSEL 6.2 14/17] net: sfp: add quirk enabling 2500Base-x for HG MXPD-483II Sasha Levin
2023-04-20 11:01 ` [PATCH AUTOSEL 6.2 15/17] platform/x86: thinkpad_acpi: Add missing T14s Gen1 type to s2idle quirk list Sasha Levin
2023-04-20 11:01 ` [PATCH AUTOSEL 6.2 16/17] wifi: ath11k: reduce the MHI timeout to 20s Sasha Levin
2023-04-20 11:01 ` [PATCH AUTOSEL 6.2 17/17] x86/cpu: Add model number for Intel Arrow Lake processor Sasha Levin

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=20230420110148.505779-4-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikelley@microsoft.com \
    --cc=mingo@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wei.liu@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).