Commit 2d72ab24 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'hyperv-fixes-signed-20230402' of...

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
parents 7e364e56 f8acb24a
...@@ -358,12 +358,16 @@ static void __init ms_hyperv_init_platform(void) ...@@ -358,12 +358,16 @@ static void __init ms_hyperv_init_platform(void)
* To mirror what Windows does we should extract CPU management * To mirror what Windows does we should extract CPU management
* features and use the ReservedIdentityBit to detect if Linux is the * features and use the ReservedIdentityBit to detect if Linux is the
* root partition. But that requires negotiating CPU management * 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 * Hyper-V should never specify running as root and as a Confidential
* root. * 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; hv_root_partition = true;
pr_info("Hyper-V: running as root partition\n"); pr_info("Hyper-V: running as root partition\n");
} }
......
...@@ -409,6 +409,10 @@ void vmbus_disconnect(void) ...@@ -409,6 +409,10 @@ void vmbus_disconnect(void)
*/ */
struct vmbus_channel *relid2channel(u32 relid) struct vmbus_channel *relid2channel(u32 relid)
{ {
if (vmbus_connection.channels == NULL) {
pr_warn_once("relid2channel: relid=%d: No channels mapped!\n", relid);
return NULL;
}
if (WARN_ON(relid >= MAX_CHANNEL_RELIDS)) if (WARN_ON(relid >= MAX_CHANNEL_RELIDS))
return NULL; return NULL;
return READ_ONCE(vmbus_connection.channels[relid]); return READ_ONCE(vmbus_connection.channels[relid]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment