From: Baolu Lu <baolu.lu@linux.intel.com>
To: Nicolin Chen <nicolinc@nvidia.com>,
joro@8bytes.org, Jason Gunthorpe <jgg@nvidia.com>
Cc: baolu.lu@linux.intel.com, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Kevin Tian <kevin.tian@intel.com>,
Jean-Philippe Brucker <jpb@kernel.org>,
Yi Liu <yi.l.liu@intel.com>,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 2/4] iommu: Unpublish the attach handle before the PASID detach callback
Date: Sun, 1 Nov 2026 10:13:20 +0800 [thread overview]
Message-ID: <762aa8ba-8e4a-420f-81d6-607c79d9363a@linux.intel.com> (raw)
In-Reply-To: <3d6731c5c3502380b4de3c90a1f6ba5547f0dd85.1790718296.git.nicolinc@nvidia.com>
On 9/30/2026 5:51 AM, Nicolin Chen wrote:
> iommu_detach_device_pasid() erases the group->pasid_array entry only once
> __iommu_remove_group_pasid() has returned, so the detaching handle stays
> visible to iommu_attach_handle_get() for the whole of that callback, and
> the caller frees it as soon as the detach returns.
>
> Erase the entry ahead of the callback, for the same reason the group path
> does: a fault raised in the meantime must not resolve to a domain that is
> on its way out.
>
> Fixes: 16603704559c ("iommu: Add attach/detach_dev_pasid iommu interfaces")
> Cc:stable@vger.kernel.org
> Assisted-by: LLM
ditto
> Signed-off-by: Nicolin Chen<nicolinc@nvidia.com>
> ---
> drivers/iommu/iommu.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index a062a84686c29..19b880d23314b 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -3818,8 +3818,12 @@ void iommu_detach_device_pasid(struct iommu_domain *domain, struct device *dev,
> struct iommu_group *group = dev->iommu_group;
>
> mutex_lock(&group->mutex);
> - __iommu_remove_group_pasid(group, pasid, domain);
> + /*
> + * Unpublish the handle first, so it would not resolve to the detaching
> + * domain once the driver is detaching it.
> + */
> xa_erase(&group->pasid_array, pasid);
> + __iommu_remove_group_pasid(group, pasid, domain);
> mutex_unlock(&group->mutex);
> }
> EXPORT_SYMBOL_GPL(iommu_detach_device_pasid);
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
next prev parent reply other threads:[~2026-11-01 2:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 21:51 [PATCH v1 0/4] iommu: Fix attach handle publication ordering Nicolin Chen
2026-09-29 21:51 ` [PATCH v1 1/4] iommu: Unpublish the attach handle before the group detach callback Nicolin Chen
2026-10-29 7:18 ` Tian, Kevin
2026-11-01 2:01 ` Baolu Lu
2026-09-29 21:51 ` [PATCH v1 2/4] iommu: Unpublish the attach handle before the PASID " Nicolin Chen
2026-10-29 7:18 ` Tian, Kevin
2026-11-01 2:13 ` Baolu Lu [this message]
2026-09-29 21:51 ` [PATCH v1 3/4] iommu: Unpublish the old attach handle before the group replace callback Nicolin Chen
2026-10-29 7:25 ` Tian, Kevin
2026-10-29 11:00 ` Yi Liu
2026-10-29 18:45 ` Jason Gunthorpe
2026-10-30 8:03 ` Tian, Kevin
2026-10-30 8:22 ` Yi Liu
2026-10-30 15:21 ` Jason Gunthorpe
2026-11-01 5:53 ` Baolu Lu
2026-09-29 21:51 ` [PATCH v1 4/4] iommu: Unpublish the old attach handle before the PASID " Nicolin Chen
2026-10-29 7:26 ` Tian, Kevin
2026-11-01 5:54 ` Baolu Lu
2026-10-28 18:58 ` [PATCH v1 0/4] iommu: Fix attach handle publication ordering Nicolin Chen
2026-10-29 11:00 ` Yi Liu
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=762aa8ba-8e4a-420f-81d6-607c79d9363a@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=jpb@kernel.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolinc@nvidia.com \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
--cc=yi.l.liu@intel.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
all inboxes | Powered by JetHome®