From: sashiko-bot@kernel.org
To: "Thara Gopinath" <tgopinath@linux.microsoft.com>
Cc: linux-hyperv@vger.kernel.org
Subject: Re: [RFC PATCH 09/12] drivers: hv: hv_vsm_boot: Enable VTL1 on the boot processor
Date: Tue, 01 Sep 2026 17:36:03 +0000 [thread overview]
Message-ID: <20260901173604.66DAC1F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260901165647.3160413-10-tgopinath@linux.microsoft.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Unconditional loading of the secure kernel overwrites VTL1 memory even if VTL1 is already active, leading to memory corruption or fatal faults.
Pre-existing issues:
- [High] Missing bounds check when parsing ELF program headers from firmware, leading to potential out-of-bounds read.
--
commit 58f06b8de69e2f750e55a8ff7220ab38d88c0f8f
Author: Thara Gopinath <tgopinath@linux.microsoft.com>
drivers: hv: hv_vsm_boot: Enable VTL1 on the boot processor
This commit introduces helpers to get VP status and enable VTL1 on the boot
virtual processor. It extends hv_vsm_bootstrap_vtl() to enable VTL1 on the
boot VP if it is not already enabled, and re-queries the status to confirm
the transition.
> diff --git a/drivers/hv/hv_vsm_boot.c b/drivers/hv/hv_vsm_boot.c
> index dc20f935da5b2..abe82e03e1897 100644
> --- a/drivers/hv/hv_vsm_boot.c
> +++ b/drivers/hv/hv_vsm_boot.c
> @@ -216,6 +216,47 @@ static int __init hv_vsm_load_secure_kernel(Elf64_Addr *sk_entry_pa)
> return ret;
> }
[Severity: High]
This isn't a bug introduced by this patch, but there appears to be a missing
bounds check when parsing ELF program headers from the firmware in
hv_vsm_load_elf() which is called by hv_vsm_load_secure_kernel().
The firmware size (fw->size) is discarded instead of being passed to
hv_vsm_load_elf() for validation. Inside hv_vsm_load_elf(), the program header
table offset (e_phoff) is never bounds-checked against the firmware size before
being iterated over:
drivers/hv/hv_vsm_boot.c:hv_vsm_load_elf() {
...
Elf64_Phdr *phdr = image + ehdr->e_phoff;
...
}
Later, the memcpy() copies uncontrolled lengths of kernel memory based on
untrusted firmware headers:
drivers/hv/hv_vsm_boot.c:hv_vsm_load_elf() {
...
memcpy(load_addr, image + phdr->p_offset, phdr->p_filesz);
...
}
Could a malformed or maliciously crafted firmware file cause an out-of-bounds
read past the end of the firmware buffer, potentially leaking sensitive kernel
data into the secure kernel's memory or causing a kernel panic?
[ ... ]
> @@ -300,7 +342,34 @@ static int __init hv_vsm_bootstrap_vtl(void)
> }
> }
>
> - return hv_vsm_load_secure_kernel(&sk_entry_pa);
> + ret = hv_vsm_load_secure_kernel(&sk_entry_pa);
> + if (ret)
> + return ret;
> +
> + /* Check and enable VTL1 for the primary virtual processor */
> + ret = hv_vsm_get_vp_status(&vp_enabled_vtl_set, &active_mbec_enabled);
> + if (ret)
> + return ret;
> +
> + if (vp_enabled_vtl_set & HV_VTL1_ENABLE_BIT) {
> + pr_info("VP VTL1 is already enabled\n");
[Severity: High]
If VTL1 is already enabled, does calling hv_vsm_load_secure_kernel() earlier
in this function overwrite the memory of the currently running VTL1 secure
kernel?
Since hv_vsm_load_secure_kernel() is called unconditionally before checking if
VP VTL1 is active, could unconditionally loading the secure kernel ELF image
cause a regression by triggering a fatal hypervisor intercept/fault in VTL0,
or silently corrupting the active VTL1 (such as during a kexec reboot)?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260901165647.3160413-1-tgopinath@linux.microsoft.com?part=9
next prev parent reply other threads:[~2026-09-01 17:36 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 16:55 [RFC PATCH 00/12] Introduce LVBS support for Hyper-V guests Thara Gopinath
2026-09-01 16:55 ` [RFC PATCH 01/12] drivers: hv: Add HYPERV_VSM kconfig option Thara Gopinath
2026-09-01 16:55 ` [RFC PATCH 02/12] drivers: hv: hv_common: Allocate Hyper-V output arg page when VSM is enabled Thara Gopinath
2026-09-01 17:12 ` sashiko-bot
2026-09-01 22:56 ` Wei Liu
2026-09-01 16:55 ` [RFC PATCH 03/12] drivers: hv: Reserve memory for VSM secure kernel during early boot Thara Gopinath
2026-09-01 17:10 ` sashiko-bot
2026-09-02 0:59 ` Wei Liu
2026-09-02 13:38 ` Thara Gopinath
2026-09-01 16:55 ` [RFC PATCH 04/12] firmware: efi: libstub: x86-stub: Enable VSM awareness in efi os indications variable Thara Gopinath
2026-09-01 17:09 ` sashiko-bot
2026-09-02 1:09 ` Wei Liu
2026-09-02 14:23 ` Thara Gopinath
2026-09-01 16:55 ` [RFC PATCH 05/12] include: hyperv: hvgdk_mini.h: Add VTL-specific structures and bits Thara Gopinath
2026-09-01 16:55 ` [RFC PATCH 06/12] drivers: hv: Add VSM boot driver and enable VTL1 at the partition level Thara Gopinath
2026-09-01 17:24 ` sashiko-bot
2026-09-02 1:16 ` Wei Liu
2026-09-02 14:28 ` Thara Gopinath
2026-09-02 4:43 ` Wei Liu
2026-09-04 13:23 ` Thara Gopinath
2026-09-01 16:55 ` [RFC PATCH 07/12] drivers: hv: hv_vsm_boot: load secure kernel image from firmware Thara Gopinath
2026-09-01 17:20 ` sashiko-bot
2026-09-02 4:37 ` Wei Liu
2026-09-02 16:22 ` Thara Gopinath
2026-09-02 22:58 ` Wei Liu
2026-09-01 16:55 ` [RFC PATCH 08/12] arch: x86: hyperv: Build initial vCPU context for VTL1 secure kernel Thara Gopinath
2026-09-01 17:25 ` sashiko-bot
2026-09-01 16:55 ` [RFC PATCH 09/12] drivers: hv: hv_vsm_boot: Enable VTL1 on the boot processor Thara Gopinath
2026-09-01 17:36 ` sashiko-bot [this message]
2026-09-01 16:55 ` [RFC PATCH 10/12] arch: x86: hyperv: hv_vtl_vsm: Introduce vtlcall Thara Gopinath
2026-09-01 16:55 ` [RFC PATCH 11/12] drivers: hv: hv_vsm_boot: Boot primary processor in VTL1 Thara Gopinath
2026-09-01 17:35 ` sashiko-bot
2026-09-01 16:55 ` [RFC PATCH 12/12] drivers: hv: hv_vsm_boot: Boot secondary processors " Thara Gopinath
2026-09-01 17:44 ` sashiko-bot
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=20260901173604.66DAC1F00A3E@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tgopinath@linux.microsoft.com \
/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