From: sashiko-bot@kernel.org
To: "Mikko Perttunen" <mperttunen@nvidia.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v4 08/12] iommu: Enable DMA default domains on (most) 32-bit ARM platforms
Date: Wed, 18 Nov 2026 01:14:30 +0000 [thread overview]
Message-ID: <sashiko-outbox-219899@kernel.org> (raw)
In-Reply-To: <20261118-b4-arm32-iommu-dma-cookie-v4-8-0c5561288e22@nvidia.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] iommu/rockchip: use-after-free on device teardown with DMA
default domain
--
commit 8d1920bbbf8a787c5aa107cb5120874184f3935a
Author: Mikko Perttunen <mperttunen@nvidia.com>
iommu: Enable DMA default domains on (most) 32-bit ARM platforms
This commit removes the unconditional IOMMU_DOMAIN_IDENTITY override for
CONFIG_ARM_DMA_USE_IOMMU in iommu_get_default_domain_type(), allowing
32-bit ARM platforms to use DMA default domains except on drivers that
explicitly opt out via def_domain_type.
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 31c5e336dac76..2eaae4818913d 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -1887,18 +1887,6 @@ static int iommu_get_default_domain_type(struct iommu_group *group,
>
> lockdep_assert_held(&group->mutex);
>
> - /*
> - * ARM32 drivers supporting CONFIG_ARM_DMA_USE_IOMMU can declare an
> - * identity_domain and it will automatically become their default
> - * domain. Later on ARM_DMA_USE_IOMMU will install its UNMANAGED domain.
> - * Override the selection to IDENTITY.
> - */
> - if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) {
> - static_assert(!(IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) &&
> - IS_ENABLED(CONFIG_IOMMU_DMA)));
> - driver_type = IOMMU_DOMAIN_IDENTITY;
> - }
> -
> for_each_group_device(group, gdev) {
> driver_type = iommu_get_def_domain_type(group, gdev->dev,
> driver_type);
[Severity: High]
Does switching rockchip-iommu to a DMA default domain on 32-bit ARM cause
a use-after-free of rk_domain when a client device is removed?
Previously on 32-bit ARM, group->default_domain was the static
rk_identity_domain, and arm_teardown_iommu_dma_ops() detached the legacy
UNMANAGED domain (re-attaching rk_identity_domain and unlinking
iommu->node from rk_domain->iommus) before freeing it.
With this change, group->default_domain is a dynamically allocated
IOMMU_DOMAIN_DMA domain. On device teardown, arm_teardown_iommu_dma_ops()
returns early for DMA default domains, and iommu_deinit_device() frees
group->default_domain without detaching the device because rk_iommu_ops
sets neither release_domain nor detachment logic in
rk_iommu_release_device():
drivers/iommu/rockchip-iommu.c:rk_iommu_release_device() {
struct rk_iommudata *data = dev_iommu_priv_get(dev);
device_link_del(data->link);
}
drivers/iommu/rockchip-iommu.c:rk_iommu_domain_free() {
struct rk_iommu_domain *rk_domain = to_rk_domain(domain);
...
WARN_ON(!list_empty(&rk_domain->iommus));
}
When the last device in the group is deinitialized, rk_iommu_domain_free()
hits the WARN_ON() and frees rk_domain while iommu->node remains on
rk_domain->iommus and iommu->domain still points to the freed domain,
which is later dereferenced in rk_iommu_resume() or rk_iommu_irq().
Setting .release_domain = &rk_identity_domain in rk_iommu_ops (or opting
rockchip-iommu out via def_domain_type) would avoid this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118-b4-arm32-iommu-dma-cookie-v4-0-0c5561288e22@nvidia.com?part=8
next prev parent reply other threads:[~2026-11-18 1:14 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 0:35 [PATCH v4 00/12] Make the 32-bit ARM DMA API work with normal IOMMU DMA default domains (+ Tegra PoC) Mikko Perttunen
2026-11-18 0:35 ` [PATCH v4 01/12] iommu: Initialize default domain policy at core initcall level Mikko Perttunen
2026-11-18 0:35 ` [PATCH v4 02/12] iommu: Add iommu_teardown_dma_ops Mikko Perttunen
2026-11-18 0:35 ` [PATCH v4 03/12] iommu: Add cookie type for ARM_DMA_USE_IOMMU Mikko Perttunen
2026-11-18 0:35 ` [PATCH v4 04/12] ARM: dma-mapping: Split mapping initialization from allocation Mikko Perttunen
2026-11-18 0:35 ` [PATCH v4 05/12] ARM: dma-mapping: Implement and expose DMA setup functions Mikko Perttunen
2026-11-18 0:35 ` [PATCH v4 06/12] ARM: dma-mapping: Bypass the legacy path for core-owned DMA API domains Mikko Perttunen
2026-11-18 0:35 ` [PATCH v4 07/12] ARM: dma-mapping: Bound IOVA allocation by device DMA limits Mikko Perttunen
2026-11-18 0:35 ` [PATCH v4 08/12] iommu: Enable DMA default domains on (most) 32-bit ARM platforms Mikko Perttunen
2026-11-18 1:14 ` sashiko-bot [this message]
2026-11-18 0:35 ` [PATCH v4 09/12] drm/tegra: Fix device parameter to dma_get_sgtable Mikko Perttunen
2026-11-18 0:51 ` sashiko-bot
2026-11-18 0:35 ` [PATCH v4 10/12] iommu/tegra-smmu: Defer display client translation to driver handover Mikko Perttunen
2026-11-18 0:35 ` [PATCH v4 11/12] iommu/tegra-smmu: Release previous address space on paging domain switch Mikko Perttunen
2026-11-18 0:35 ` [PATCH v4 12/12] iommu/tegra-smmu: Use a DMA API default domain per swgroup Mikko Perttunen
2026-11-18 1:01 ` sashiko-bot
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=sashiko-outbox-219899@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=mperttunen@nvidia.com \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.