x86/hyperv: Block root partition functionality in a Confidential VM
Subsystems (3)
PATCH 1/1 x86/hyperv: Block root partition functionality in a Confidential VM
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.
--- arch/x86/kernel/cpu/mshyperv.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/mshyperv.c +8 -4
@@ -356,12 +356,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" ); }
Signature · 1 line
1.8.3.1
Quoted 8 lines · Michael Kelley
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 <[email protected]>
Applied to hyperv-fixes. Thanks.
Quoted 32 lines
--- arch/x86/kernel/cpu/mshyperv.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)arch/x86/kernel/cpu/mshyperv.c +8
-4@@ -356,12 +356,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" ); }Signature · 1 line
1.8.3.1