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 v6 4/5] iommu/hyperv: Add para-virtualized IOMMU support for Hyper-V guest
Date: Wed, 30 Sep 2026 14:37:23 +0000 [thread overview]
Message-ID: <20260930143724.65BEE1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260930141409.437904-5-zhangyu1@linux.microsoft.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] iommu/hyperv: missing detach causes silent attach failures
- [Medium] iommu/hyperv: page table UAF due to wrong domain teardown order
- [Low] iommu/hyperv: missing MODULE_IMPORT_NS causes modpost warning
--
commit e9c9e7afc1e982c251a775443c1fa2af0f333b80
Author: Yu Zhang <zhangyu1@linux.microsoft.com>
iommu/hyperv: Add para-virtualized IOMMU support for Hyper-V guest
Add a para-virtualized IOMMU driver for Linux guests running on Hyper-V.
This driver implements stage-1 IO translation within 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
index 0000000000000..341d70eed5924
--- /dev/null
+++ b/drivers/iommu/hyperv/hv-iommu-guest.c
[ ... ]
> +static int hv_iommu_attach_dev(struct iommu_domain *domain, struct device *dev,
> + struct iommu_domain *old)
> +{
[ ... ]
> + status = hv_do_hypercall(HVCALL_ATTACH_DEVICE_DOMAIN, input, NULL);
> +
> + local_irq_restore(flags);
> +
> + if (!hv_result_success(status) &&
> + hv_result(status) != HV_STATUS_DEVICE_ALREADY_IN_DOMAIN) {
[Severity: High]
If a device is already attached to a domain (e.g., blocking or identity),
HVCALL_ATTACH_DEVICE_DOMAIN fails with HV_STATUS_DEVICE_ALREADY_IN_DOMAIN.
By ignoring this error code and returning success without detaching from
the old domain first, does the IOMMU core assume the device is successfully
isolated in the new domain while it actually remains in the old domain?
Could this silently break DMA isolation?
> + hv_status_err(status, "HVCALL_ATTACH_DEVICE_DOMAIN failed\n");
> + return hv_result_to_errno(status);
> + }
> +
> + if (domain != &hv_blocking_domain.domain &&
> + !pdev->ats_enabled &&
[ ... ]
> +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: Medium]
In hv_iommu_paging_domain_free(), the driver frees the guest memory backing
the page tables via pt_iommu_deinit() before instructing the hypervisor to
destroy the domain via hv_delete_device_domain().
Since the hypervisor's device domain is still active and holds the page
table root pointer, could the hypervisor access freed memory if it performs
background invalidations or delayed faults before the domain is destroyed?
Should the domain be deleted before the page tables are freed?
> +
> + kfree(hv_domain);
> +}
[ ... ]
> +static struct iommu_domain *hv_iommu_domain_alloc_paging(struct device *dev)
> +{
[ ... ]
> + cfg.top_level = (hv_iommu_device->max_iova_width > 48) ? 4 : 3;
> +
> + ret = pt_iommu_x86_64_init(&hv_domain->pt_iommu_x86_64, &cfg, GFP_KERNEL);
[Severity: Low]
The driver selects GENERIC_PT and calls pt_iommu_x86_64_init(), which is
exported into the GENERIC_PT_IOMMU namespace.
Without a MODULE_IMPORT_NS("GENERIC_PT_IOMMU") declaration, will this
cause modpost warnings during the kernel build?
> + if (ret)
> + goto err_free;
> +
> + /* Constrain to page sizes the hypervisor supports */
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260930141409.437904-1-zhangyu1@linux.microsoft.com?part=4
next prev parent reply other threads:[~2026-09-30 14:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 14:14 [PATCH v6 0/5] Hyper-V: Add para-virtualized IOMMU support for Linux guests Yu Zhang
2026-09-30 14:14 ` [PATCH v6 1/5] hyperv: Introduce new hypercall interfaces used by Hyper-V guest IOMMU Yu Zhang
2026-09-30 14:27 ` sashiko-bot
2026-09-30 14:14 ` [PATCH v6 2/5] Drivers: hv: Add logical device ID registry for vPCI devices Yu Zhang
2026-09-30 14:26 ` sashiko-bot
2026-09-30 14:14 ` [PATCH v6 3/5] iommu/x86: Add architectural MSI reserved region helper Yu Zhang
2026-09-30 14:20 ` sashiko-bot
2026-10-01 12:07 ` Vasant Hegde
2026-09-30 14:14 ` [PATCH v6 4/5] iommu/hyperv: Add para-virtualized IOMMU support for Hyper-V guest Yu Zhang
2026-09-30 14:37 ` sashiko-bot [this message]
2026-09-30 14:14 ` [PATCH v6 5/5] iommu/hyperv: Add page-selective IOTLB flush support Yu Zhang
2026-09-30 14:36 ` 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=20260930143724.65BEE1F000FF@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