From: sashiko-bot@kernel.org
To: "Yu Zhang" <zhangyu1@linux.microsoft.com>
Cc: linux-pci@vger.kernel.org, linux-hyperv@vger.kernel.org
Subject: Re: [PATCH v4 4/5] iommu/hyperv: Add para-virtualized IOMMU support for Hyper-V guest
Date: Fri, 21 Aug 2026 13:45:25 +0000 [thread overview]
Message-ID: <20260821134525.ADB931F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260821132654.211730-5-zhangyu1@linux.microsoft.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Page tables are freed before deleting the device domain from the hypervisor, leading to a Use-After-Free risk.
--
--- Patch [4]: [PATCH v4 4/5] iommu/hyperv: Add para-virtualized IOMMU support for Hyper-V guest ---
commit 7152dacb77d4624afa4df5d0624b6de801e9959e
Author: Yu Zhang <zhangyu1@linux.microsoft.com>
iommu/hyperv: Add para-virtualized IOMMU support for Hyper-V guest
This commit adds a para-virtualized IOMMU driver for Linux guests on
Hyper-V. It implements stage-1 IO translation in the guest OS and integrates
with the Linux IOMMU core utilizing Hyper-V hypercalls.
> diff --git a/drivers/iommu/hyperv/hv-iommu-guest.c b/drivers/iommu/hyperv/hv-iommu-guest.c
> new file mode 100644
> --- /dev/null
> +++ b/drivers/iommu/hyperv/hv-iommu-guest.c
[ ... ]
> +static void hv_iommu_paging_domain_free(struct iommu_domain *domain)
> +{
> + struct hv_iommu_domain *hv_domain = to_hv_iommu_domain(domain);
> +
> + /* Free all remaining mappings */
> + pt_iommu_deinit(&hv_domain->pt_iommu);
> +
> + hv_delete_device_domain(hv_domain);
[Severity: High]
Could this cause a use-after-free of guest memory?
The guest kernel frees the page tables by calling pt_iommu_deinit() first,
returning the physical pages to the allocator while the hypervisor still
holds a reference to the page table root for this device domain.
If the hypervisor accesses the page tables during the subsequent
HVCALL_DELETE_DEVICE_DOMAIN hypercall (for cleanup, nested cache flushes,
or shadow unmapping), it might read or write to reallocated memory.
Should hv_delete_device_domain() be called before pt_iommu_deinit(),
similar to how teardown is ordered in the hv_iommu_domain_alloc_paging()
error path?
> +
> + kfree(hv_domain);
> +}
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260821132654.211730-1-zhangyu1@linux.microsoft.com?part=4
next prev parent reply other threads:[~2026-08-21 13:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 13:26 [PATCH v4 0/5] Hyper-V: Add para-virtualized IOMMU support for Linux guests Yu Zhang
2026-08-21 13:26 ` [PATCH v4 1/5] hyperv: Introduce new hypercall interfaces used by Hyper-V guest IOMMU Yu Zhang
2026-08-21 13:41 ` sashiko-bot
2026-08-28 17:21 ` Michael Kelley
2026-08-21 13:26 ` [PATCH v4 2/5] Drivers: hv: Add logical device ID registry for vPCI devices Yu Zhang
2026-08-21 13:33 ` sashiko-bot
2026-08-28 17:21 ` Michael Kelley
2026-08-21 13:26 ` [PATCH v4 3/5] iommu/x86: Add architectural MSI reserved region helper Yu Zhang
2026-08-21 13:33 ` sashiko-bot
2026-08-28 17:21 ` Michael Kelley
2026-08-21 13:26 ` [PATCH v4 4/5] iommu/hyperv: Add para-virtualized IOMMU support for Hyper-V guest Yu Zhang
2026-08-21 13:45 ` sashiko-bot [this message]
2026-08-28 17:22 ` Michael Kelley
2026-09-03 8:01 ` Yu Zhang
2026-08-21 13:26 ` [PATCH v4 5/5] iommu/hyperv: Add page-selective IOTLB flush support Yu Zhang
2026-08-21 13:41 ` sashiko-bot
2026-08-28 17:22 ` Michael Kelley
2026-09-03 8:09 ` Yu Zhang
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=20260821134525.ADB931F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zhangyu1@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