* [PATCH] iommu/vt-d: Fix iopf_refcount leak in nested RID replacement
@ 2026-09-24 11:50 Jiale Yao
2026-10-06 2:11 ` Baolu Lu
0 siblings, 1 reply; 2+ messages in thread
From: Jiale Yao @ 2026-09-24 11:50 UTC (permalink / raw)
To: David Woodhouse, Lu Baolu, Joerg Roedel (AMD),
Will Deacon, Robin Murphy, iommu, linux-kernel
Cc: Jiale Yao
intel_nested_attach_dev() enables IOPF for the new nested domain without
releasing the reference held by the old domain. Replacing a domain with
an IOPF-enabled domain therefore leaves an extra reference in
info->iopf_refcount.
Commit 236dd58fabd2 ("iommu/vt-d: Fix iopf_refcount leak on RID
domain replacement") fixed the same IOPF reference leak in the regular
RID attach paths. The nested RID attach path has the same old-domain
handling bug.
Use iopf_for_domain_replace() for the attach and restore the old domain
reference if nested PASID setup fails, matching the existing PASID path.
Signed-off-by: Jiale Yao <yaojiale02@163.com>
Link: https://lore.kernel.org/all/20260731054329.2948252-4-baolu.lu@linux.intel.com/
---
drivers/iommu/intel/nested.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/intel/nested.c b/drivers/iommu/intel/nested.c
index 2b979bec56ce..dbcec6093d50 100644
--- a/drivers/iommu/intel/nested.c
+++ b/drivers/iommu/intel/nested.c
@@ -50,7 +50,7 @@ static int intel_nested_attach_dev(struct iommu_domain *domain,
if (ret)
goto detach_iommu;
- ret = iopf_for_domain_set(domain, dev);
+ ret = iopf_for_domain_replace(domain, old, dev);
if (ret)
goto unassign_tag;
@@ -67,7 +67,7 @@ static int intel_nested_attach_dev(struct iommu_domain *domain,
return 0;
disable_iopf:
- iopf_for_domain_remove(domain, dev);
+ iopf_for_domain_replace(old, domain, dev);
unassign_tag:
cache_tag_unassign_domain(dmar_domain, dev, IOMMU_NO_PASID);
detach_iommu:
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] iommu/vt-d: Fix iopf_refcount leak in nested RID replacement
2026-09-24 11:50 [PATCH] iommu/vt-d: Fix iopf_refcount leak in nested RID replacement Jiale Yao
@ 2026-10-06 2:11 ` Baolu Lu
0 siblings, 0 replies; 2+ messages in thread
From: Baolu Lu @ 2026-10-06 2:11 UTC (permalink / raw)
To: Jiale Yao, David Woodhouse, Joerg Roedel (AMD),
Will Deacon, Robin Murphy, iommu, linux-kernel
Cc: baolu.lu
On 9/24/2026 7:50 PM, Jiale Yao wrote:
> intel_nested_attach_dev() enables IOPF for the new nested domain without
> releasing the reference held by the old domain. Replacing a domain with
> an IOPF-enabled domain therefore leaves an extra reference in
> info->iopf_refcount.
>
> Commit 236dd58fabd2 ("iommu/vt-d: Fix iopf_refcount leak on RID
> domain replacement") fixed the same IOPF reference leak in the regular
> RID attach paths. The nested RID attach path has the same old-domain
> handling bug.
>
> Use iopf_for_domain_replace() for the attach and restore the old domain
> reference if nested PASID setup fails, matching the existing PASID path.
>
> Signed-off-by: Jiale Yao <yaojiale02@163.com>
> Link: https://lore.kernel.org/all/20260731054329.2948252-4-baolu.lu@linux.intel.com/
> ---
> drivers/iommu/intel/nested.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iommu/intel/nested.c b/drivers/iommu/intel/nested.c
> index 2b979bec56ce..dbcec6093d50 100644
> --- a/drivers/iommu/intel/nested.c
> +++ b/drivers/iommu/intel/nested.c
> @@ -50,7 +50,7 @@ static int intel_nested_attach_dev(struct iommu_domain *domain,
> if (ret)
> goto detach_iommu;
>
> - ret = iopf_for_domain_set(domain, dev);
> + ret = iopf_for_domain_replace(domain, old, dev);
> if (ret)
> goto unassign_tag;
>
> @@ -67,7 +67,7 @@ static int intel_nested_attach_dev(struct iommu_domain *domain,
>
> return 0;
> disable_iopf:
> - iopf_for_domain_remove(domain, dev);
> + iopf_for_domain_replace(old, domain, dev);
> unassign_tag:
> cache_tag_unassign_domain(dmar_domain, dev, IOMMU_NO_PASID);
> detach_iommu:
Thanks for the patch, but we already have a fix in the iommu tree:
83871c3ae10e ("iommu/vt-d: Fix iopf refcount leak in nested attach")
Thanks,
baolu
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-06 2:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-24 11:50 [PATCH] iommu/vt-d: Fix iopf_refcount leak in nested RID replacement Jiale Yao
2026-10-06 2:11 ` Baolu Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®