lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20ba4b7c-bebb-4b1f-8c6c-4cd52a5083b5@linux.microsoft.com>
Date: Tue, 11 Feb 2025 21:47:24 -0800
From: Easwar Hariharan <eahariha@...ux.microsoft.com>
To: Nuno Das Neves <nunodasneves@...ux.microsoft.com>
Cc: linux-hyperv@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
 linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org,
 iommu@...ts.linux.dev, eahariha@...ux.microsoft.com, kys@...rosoft.com,
 haiyangz@...rosoft.com, wei.liu@...nel.org, mhklinux@...look.com,
 decui@...rosoft.com, catalin.marinas@....com, will@...nel.org,
 tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
 dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
 daniel.lezcano@...aro.org, joro@...tes.org, robin.murphy@....com,
 arnd@...db.de, jinankjain@...ux.microsoft.com, muminulrussell@...il.com,
 skinsburskii@...ux.microsoft.com, mukeshrathor@...rosoft.com
Subject: Re: [PATCH] hyperv: Add CONFIG_MSHV_ROOT to gate hv_root_partition
 checks

On 2/11/2025 2:21 PM, Nuno Das Neves wrote:
> Introduce CONFIG_MSHV_ROOT as a tristate to enable root partition
> booting and future mshv driver functionality.
> 
> Change hv_root_partition into a function which always returns false
> if CONFIG_MSHV_ROOT=n.
> 
> Introduce hv_current_partition_type to store the type of partition
> (guest, root, or other kinds in future), and hv_identify_partition_type()
> to it up early in Hyper-V initialization.

...to *set* it up early?

> 
> Signed-off-by: Nuno Das Neves <nunodasneves@...ux.microsoft.com>
> ---
> Depends on
> https://lore.kernel.org/linux-hyperv/1738955002-20821-3-git-send-email-nunodasneves@linux.microsoft.com/
> 
>  arch/arm64/hyperv/mshyperv.c       |  2 ++
>  arch/x86/hyperv/hv_init.c          | 10 ++++----
>  arch/x86/kernel/cpu/mshyperv.c     | 24 ++----------------
>  drivers/clocksource/hyperv_timer.c |  4 +--
>  drivers/hv/Kconfig                 | 12 +++++++++
>  drivers/hv/Makefile                |  3 ++-
>  drivers/hv/hv.c                    | 10 ++++----
>  drivers/hv/hv_common.c             | 32 +++++++++++++++++++-----
>  drivers/hv/vmbus_drv.c             |  2 +-
>  drivers/iommu/hyperv-iommu.c       |  4 +--
>  include/asm-generic/mshyperv.h     | 39 +++++++++++++++++++++++++-----
>  11 files changed, 92 insertions(+), 50 deletions(-)
> 

<snip>

> +
> +void hv_identify_partition_type(void)
> +{
> +	/*
> +	 * Check partition creation and cpu management privileges
> +	 *
> +	 * 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 ((ms_hyperv.priv_high & HV_CREATE_PARTITIONS) &&
> +	    (ms_hyperv.priv_high & HV_CPU_MANAGEMENT) &&
> +	    !(ms_hyperv.priv_high & HV_ISOLATION)) {
> +		hv_current_partition_type = HV_PARTITION_TYPE_ROOT;
> +		pr_info("Hyper-V: running as root partition\n");
> +	} else {
> +		hv_current_partition_type = HV_PARTITION_TYPE_GUEST;
> +	}
> +}

This should assume GUEST as default and modify to ROOT if all the checks pass.

<snip>

> +static inline int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages)
> +{
> +	return hv_result(U64_MAX);
> +}

Is there value in perhaps #defining hv_result_<whatever this is> as U64_MAX and returning that for documentation?
For e.g. assuming this is something like EOPNOTSUPP

#define HV_RESULT_NOT_SUPP U64_MAX

static inline int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages)
{ return hv_result(HV_RESULT_NOT_SUPP); }

<snip>

Thanks,
Easwar (he/him)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ