From: sashiko-bot@kernel.org
To: "Sven Püschel" <s.pueschel@pengutronix.de>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH 14/17] media: rockchip: rga: put all cores into first core iommu domain
Date: Fri, 05 Jun 2026 22:23:06 +0000 [thread overview]
Message-ID: <20260605222307.3B3BC1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260606-spu-rga3multicore-v1-14-3ec2b15675f7@pengutronix.de>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Critical] Sharing the primary core's default IOMMU domain with secondary cores creates a severe lifetime mismatch leading to a Use-After-Free if the primary core is removed.
- [High] Incorrect error checking of `iommu_get_domain_for_dev()` using `IS_ERR()` causes a NULL pointer dereference and masks errors.
- [High] The new error paths for IOMMU attachment fail to release the PM runtime reference.
- [High] Missing `.unbind` callback leads to IOMMU domain reference leaks, teardown asymmetry, and array out-of-bounds writes upon driver rebind.
--
commit 3fbaee68845794dcb5e7c93168eef670817da976
Author: Sven Püschel <s.pueschel@pengutronix.de>
media: rockchip: rga: put all cores into first core iommu domain
Put all cores into the iommu domain of the first core to allow them to
be used by any core.
> diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c
> --- a/drivers/media/platform/rockchip/rga/rga.c
> +++ b/drivers/media/platform/rockchip/rga/rga.c
> @@ -757,6 +758,19 @@ static int rga_core_bind(struct device *dev, struct device *master, void *data)
> version.major, version.minor);
>
> if (rga->num_cores) {
> + /* Attach to the first cores iommu */
> + struct iommu_domain *domain = iommu_get_domain_for_dev(rga->cores[0]->dev);
> +
> + if (IS_ERR(domain)) {
[Severity: High]
Since iommu_get_domain_for_dev() returns NULL on failure (not an ERR_PTR),
won't this IS_ERR() check fail to catch a NULL domain?
If domain is NULL, it will be passed to iommu_attach_device(), which could
lead to a NULL pointer dereference when accessing domain->owner in
domain_iommu_ops_compatible().
> + dev_err(core->dev, "Couldn't get domain of the first core\n");
> + return PTR_ERR(domain);
[Severity: High]
Does this early return leak the PM runtime reference?
pm_runtime_resume_and_get(core->dev) is called earlier in this function, but
this return path doesn't call pm_runtime_put(core->dev).
> + }
> + ret = iommu_attach_device(domain, core->dev);
[Severity: Critical]
Does sharing the primary core's default IOMMU domain with secondary cores
create a lifetime mismatch?
The IOMMU subsystem couples the lifetime of a default domain strictly to its
original device group. If the platform device for the first core is removed,
the IOMMU core frees the default domain in iommu_deinit_device().
Secondary cores would still retain pointers to this freed domain, leading to a
use-after-free during DMA operations or unbinding.
[Severity: High]
Since we are attaching the device to the IOMMU domain here, how is it
detached when the driver is unbound?
There does not appear to be a corresponding .unbind callback in
rga_core_ops to call iommu_detach_device(). This would leave the IOMMU
group permanently attached, causing subsequent rebinds to fail with -EBUSY
or leak references.
Additionally, without an unbind callback to reset rga->num_cores, won't
re-binding the components cause rga->cores[rga->num_cores++] to continue
incrementing and overflow the array?
> + if (ret) {
> + dev_err(core->dev, "Couldn't attach to the domain of the first core\n");
> + return ret;
[Severity: High]
Could this return path also leak the PM runtime reference acquired by
pm_runtime_resume_and_get(core->dev)?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260606-spu-rga3multicore-v1-0-3ec2b15675f7@pengutronix.de?part=14
next prev parent reply other threads:[~2026-06-05 22:23 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 22:06 [PATCH 00/17] media: rockchip: rga: Add multi-core support Sven Püschel
2026-06-05 22:06 ` [PATCH 01/17] media: rockchip: rga: zero cmdbuf in shared code Sven Püschel
2026-06-05 22:20 ` sashiko-bot
2026-06-05 22:06 ` [PATCH 02/17] media: rockchip: rga: add comment about pixel alignment for YUV formats Sven Püschel
2026-06-05 22:06 ` [PATCH 03/17] media: rockchip: rga: move early return into if condition in vidioc_enum_fmt Sven Püschel
2026-06-05 22:06 ` [PATCH 04/17] media: rockchip: rga: removed unused regmap member Sven Püschel
2026-06-05 22:06 ` [PATCH 05/17] media: v4l2-mem2mem: support running multiple jobs in parallel Sven Püschel
2026-06-05 22:18 ` sashiko-bot
2026-06-05 22:06 ` [PATCH 06/17] media: rockchip: rga: move power handling to device_run Sven Püschel
2026-06-05 22:22 ` sashiko-bot
2026-06-05 22:06 ` [PATCH 07/17] media: rockchip: rga: adjust get_version to return the version Sven Püschel
2026-06-05 22:06 ` [PATCH 08/17] media: rockchip: rga: add rga_core structure Sven Püschel
2026-06-05 22:22 ` sashiko-bot
2026-06-05 22:06 ` [PATCH 09/17] media: rockchip: rga: use components to manage multiple cores Sven Püschel
2026-06-05 22:24 ` sashiko-bot
2026-06-05 22:06 ` [PATCH 10/17] media: rockchip: rga: move rockchip_rga allocation to master probe Sven Püschel
2026-06-05 22:23 ` sashiko-bot
2026-06-05 22:06 ` [PATCH 11/17] media: rockchip: rga: move video device to the master Sven Püschel
2026-06-05 22:21 ` sashiko-bot
2026-06-05 22:06 ` [PATCH 12/17] media: rockchip: rga: move core initialization from bind to probe Sven Püschel
2026-06-05 22:20 ` sashiko-bot
2026-06-05 22:06 ` [PATCH 13/17] media: rockchip: rga: bind all cores to the master Sven Püschel
2026-06-05 22:23 ` sashiko-bot
2026-06-05 22:07 ` [PATCH 14/17] media: rockchip: rga: put all cores into first core iommu domain Sven Püschel
2026-06-05 22:23 ` sashiko-bot [this message]
2026-06-05 22:07 ` [PATCH 15/17] media: rockchip: rga: schedule jobs to multiple cores Sven Püschel
2026-06-05 22:25 ` sashiko-bot
2026-06-05 22:07 ` [PATCH 16/17] arm64: dts: rockchip: add rga3 dt nodes to rk3588 Sven Püschel
2026-06-05 22:07 ` [PATCH 17/17] iommu/rockchip: disable fetch dte time limit Sven Püschel
2026-06-05 22:26 ` 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=20260605222307.3B3BC1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=s.pueschel@pengutronix.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox