From: Peter Chen <peter.chen@oss.qualcomm.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Kevin Tian <kevin.tian@intel.com>,
Lu Baolu <baolu.lu@linux.intel.com>,
Johan Hovold <johan@kernel.org>,
Fenglin Wu <fenglin.wu@oss.qualcomm.com>,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, linux-arm-msm@vger.kernel.org,
Jack Pham <jack.pham@oss.qualcomm.com>,
Wesley Cheng <wesley.cheng@oss.qualcomm.com>
Subject: Re: [PATCH v2] iommu: Hold group references across bus_iommu_probe()
Date: Tue, 24 Nov 2026 18:49:23 -0800 [thread overview]
Message-ID: <awZMs6kWUvXnwXFL@hu-petche-lv.qualcomm.com> (raw)
In-Reply-To: <20261124124933.GA8680@nvidia.com>
On 26-11-24 08:49:33, Jason Gunthorpe wrote:
> On Mon, Nov 23, 2026 at 11:09:03PM -0800, Peter Chen wrote:
> > The glue driver does what upstream dwc3-imx8mp.c does in
> > dwc3_imx8mp_probe():
> >
> > of_platform_populate(node, NULL, NULL, dev);
> > pdev = of_find_device_by_node(dwc3_np);
> > dwc = platform_get_drvdata(pdev);
> > if (!dwc) {
> > /* core probe deferred, e.g. its SMMU is not there yet */
> > ret = -EPROBE_DEFER;
> > goto depopulate; /* -> platform_device_unregister() */
> > }
>
> That's not how EPROBE_DEFER is supposed to be handled :(
>
> The driver core is already setup to reprobe the child driver later
> inside of_platform_populate()
>
> Your issue is it is quite wrong to try to synchronously reach into a
> probed driver's like this from outside. Then when it fails tearing
> down the device means you defeat the natural EPROBE_DEFER.
>
> This should be asynchronous, then you won't have ordering problems.
>
Agreed.
> But OK, it is clear how you get into this situation.
Thanks. The iommu core can still see a device disappear during
bus_iommu_probe(), from glue drivers like the one above or from any
other removal, so I'd still like to fix the use-after-free in the
core.
> >
> > Yes, the list head is on the stack, but group->entry is in the
> > shared group. "Is group->entry empty" is the de-dup flag that
> > __iommu_probe_device() tests and sets under group->mutex:
> >
> > if (list_empty(&group->entry))
> > list_add_tail(&group->entry, group_list);
>
> A small comment might help. The lock seems necessary
>
Will do. In v3 I will:
- add a comment in iommu_group_list_put() explaining that
group->entry is the de-dup flag tested and set by
__iommu_probe_device() under group->mutex, and that
bus_iommu_probe() may run concurrently for other IOMMU instances;
- add the real-world scenario (a parent populates a child whose probe
defers on the IOMMU, then depopulates it) to the commit message.
Would you have more comments?
--
Thanks,
Peter Chen
prev parent reply other threads:[~2026-11-25 2:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 11:07 Peter Chen
2026-11-20 20:53 ` Jason Gunthorpe
2026-11-24 7:09 ` Peter Chen
2026-11-24 12:49 ` Jason Gunthorpe
2026-11-25 2:49 ` Peter Chen [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=awZMs6kWUvXnwXFL@hu-petche-lv.qualcomm.com \
--to=peter.chen@oss.qualcomm.com \
--cc=baolu.lu@linux.intel.com \
--cc=fenglin.wu@oss.qualcomm.com \
--cc=iommu@lists.linux.dev \
--cc=jack.pham@oss.qualcomm.com \
--cc=jgg@nvidia.com \
--cc=johan@kernel.org \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=stable@vger.kernel.org \
--cc=wesley.cheng@oss.qualcomm.com \
--cc=will@kernel.org \
/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®