Skip to content

Commit 2d72ab2

Browse files
committed
Merge tag 'hyperv-fixes-signed-20230402' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux
Pull hyperv fixes from Wei Liu: - Fix a bug in channel allocation for VMbus (Mohammed Gamal) - Do not allow root partition functionality in CVM (Michael Kelley) * tag 'hyperv-fixes-signed-20230402' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux: x86/hyperv: Block root partition functionality in a Confidential VM Drivers: vmbus: Check for channel allocation before looking up relids
2 parents 7e364e5 + f8acb24 commit 2d72ab2

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

arch/x86/kernel/cpu/mshyperv.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,16 @@ static void __init ms_hyperv_init_platform(void)
358358
* To mirror what Windows does we should extract CPU management
359359
* features and use the ReservedIdentityBit to detect if Linux is the
360360
* root partition. But that requires negotiating CPU management
361-
* interface (a process to be finalized).
361+
* interface (a process to be finalized). For now, use the privilege
362+
* flag as the indicator for running as root.
362363
*
363-
* For now, use the privilege flag as the indicator for running as
364-
* root.
364+
* Hyper-V should never specify running as root and as a Confidential
365+
* VM. But to protect against a compromised/malicious Hyper-V trying
366+
* to exploit root behavior to expose Confidential VM memory, ignore
367+
* the root partition setting if also a Confidential VM.
365368
*/
366-
if (cpuid_ebx(HYPERV_CPUID_FEATURES) & HV_CPU_MANAGEMENT) {
369+
if ((ms_hyperv.priv_high & HV_CPU_MANAGEMENT) &&
370+
!(ms_hyperv.priv_high & HV_ISOLATION)) {
367371
hv_root_partition = true;
368372
pr_info("Hyper-V: running as root partition\n");
369373
}

drivers/hv/connection.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ void vmbus_disconnect(void)
409409
*/
410410
struct vmbus_channel *relid2channel(u32 relid)
411411
{
412+
if (vmbus_connection.channels == NULL) {
413+
pr_warn_once("relid2channel: relid=%d: No channels mapped!\n", relid);
414+
return NULL;
415+
}
412416
if (WARN_ON(relid >= MAX_CHANNEL_RELIDS))
413417
return NULL;
414418
return READ_ONCE(vmbus_connection.channels[relid]);

0 commit comments

Comments
 (0)