From: Baolu Lu <baolu.lu@linux.intel.com>
To: Nicolin Chen <nicolinc@nvidia.com>,
joro@8bytes.org, Kevin Tian <kevin.tian@intel.com>,
Jason Gunthorpe <jgg@nvidia.com>
Cc: baolu.lu@linux.intel.com, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.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 v3 5/5] iommu: Reject a same-domain replace in the attach handle APIs
Date: Mon, 9 Nov 2026 11:46:07 +0800 [thread overview]
Message-ID: <9d2bb2f7-4052-44fc-9ba6-a7ad6267678f@linux.intel.com> (raw)
In-Reply-To: <1b3a334eade93a5047d51af040f1400cd563189d.1793729087.git.nicolinc@nvidia.com>
On 11/4/2026 2:07 AM, Nicolin Chen wrote:
> Both iommu_replace_group_handle() and iommu_replace_device_pasid() skip the
> driver callback when the new domain is the one currently attached. In that
> case, nothing flushes the pending faults that may still be holding the old
> handle. Then, the caller frees the old handle once the replace returns, so
> such a fault would hit a use-after-free.
>
> No caller does this today, since iommufd_device_do_replace() returns early
> when the new hwpt is the old one. However, it is only a caller convention,
> which neither API enforces.
>
> Reject a same-domain replace in both APIs with a WARN_ON, and document it
> in their kernel-docs.
>
> Suggested-by: Lu Baolu<baolu.lu@linux.intel.com>
> Reviewed-by: Yi Liu<yi.l.liu@intel.com>
> Signed-off-by: Nicolin Chen<nicolinc@nvidia.com>
> ---
> drivers/iommu/iommu.c | 36 +++++++++++++++++++++++++++++-------
> 1 file changed, 29 insertions(+), 7 deletions(-)
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
prev parent reply other threads:[~2026-11-09 3:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 18:06 [PATCH v3 0/5] iommu: Fix attach handle publication ordering Nicolin Chen
2026-11-03 18:07 ` [PATCH v3 1/5] iommu: Unpublish the attach handle before the group detach callback Nicolin Chen
2026-11-03 18:07 ` [PATCH v3 2/5] iommu: Unpublish the attach handle before the PASID " Nicolin Chen
2026-11-03 18:07 ` [PATCH v3 3/5] iommu: Unpublish the old attach handle before the group replace callback Nicolin Chen
2026-11-03 18:07 ` [PATCH v3 4/5] iommu: Unpublish the old attach handle before the PASID " Nicolin Chen
2026-11-03 18:07 ` [PATCH v3 5/5] iommu: Reject a same-domain replace in the attach handle APIs Nicolin Chen
2026-11-09 3:46 ` Baolu Lu [this message]
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=9d2bb2f7-4052-44fc-9ba6-a7ad6267678f@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®