[PATCH v3 3/5] iommu: Add iommu_get_domain_for_dev_locked() helper
Jason Gunthorpe
jgg at nvidia.com
Tue Aug 19 05:52:49 PDT 2025
On Mon, Aug 18, 2025 at 10:09:11PM -0700, Nicolin Chen wrote:
> Yes, I've thought about that. The concern is that some other place
> someday may want to use iommu_get_domain_for_dev() in similar cases
> but would find that it doesn't work. So it would have to duplicate
> the domain pointer in its "master" structure.
>
> Overall, having a _locked version feels cleaner to me.
We probably need the locked version, but it just shouldn't be called very
much..
> > With sensible internal locking
>
> Hmm, I feel this iommu_get_translation_mode() is somewhat the same
> as the current iommu_get_domain_for_dev(). It would just return the
> group->domain->type v.s. group->domain, right?
>
> This doesn't have any UAF concern though.
Yes, no UAF concern is the point
> > So that is another bunch. Not sure what will be left after.
>
> I recall that some of the drivers manages their own domains, e.g.
> drivers/gpu/drm/tegra/drm.c
>
> So, they would want more out of the domain pointer than just type.
This looks like it wants an 'is currently attached' operation
Jason
More information about the Linux-mediatek
mailing list