From: sashiko-bot@kernel.org
To: "Geert Uytterhoeven" <geert+renesas@glider.be>
Cc: devicetree@vger.kernel.org, wsa+renesas@sang-engineering.com,
linux-clk@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 05/12] pmdomain: Make genpd_get_from_provider() public
Date: Wed, 02 Sep 2026 11:40:44 +0000 [thread overview]
Message-ID: <20260902114044.8D0FA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <1e1b20976fb2b0b78684be315cdf78960efcc403.1788338320.git.geert+renesas@glider.be>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Exporting of_genpd_get_from_provider introduces an unsafe public API that returns a bare pointer to a generic_pm_domain without reference counting or external locking, enabling Use-After-Free vulnerabilities.
--
commit 3c8789e2e8b48c33d816b4234b9862d8dcb170e7
Author: Geert Uytterhoeven <geert+renesas@glider.be>
pmdomain: Make genpd_get_from_provider() public
This commit renames genpd_get_from_provider() to of_genpd_get_from_provider()
and exports it to allow PM domain drivers to look up providers directly.
> diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
> index 842c4169e2906..ac3a07066e7fc 100644
> --- a/drivers/pmdomain/core.c
> +++ b/drivers/pmdomain/core.c
[ ... ]
> @@ -2900,8 +2900,7 @@ EXPORT_SYMBOL_GPL(of_genpd_del_provider);
> * Returns a valid pointer to struct generic_pm_domain on success or ERR_PTR()
> * on failure.
> */
> -static struct generic_pm_domain *genpd_get_from_provider(
> - const struct of_phandle_args *genpdspec)
> +struct generic_pm_domain *of_genpd_get_from_provider(const struct of_phandle_args *genpdspec)
> {
> struct generic_pm_domain *genpd = ERR_PTR(-ENOENT);
> struct of_genpd_provider *provider;
> @@ -2923,6 +2922,7 @@ static struct generic_pm_domain *genpd_get_from_provider(
>
> return genpd;
> }
> +EXPORT_SYMBOL_GPL(of_genpd_get_from_provider);
[Severity: High]
Could exporting this function introduce a Use-After-Free vulnerability for
callers?
Looking at the implementation of of_genpd_get_from_provider(), it searches
for the provider while holding of_genpd_mutex, but drops the lock before
returning the bare generic_pm_domain pointer. Since generic_pm_domain does
not appear to use a kref or external synchronization mechanism, the returned
pointer is left completely unprotected once the lock is dropped.
If the provider is concurrently unregistered (for example, via unbinding the
device from sysfs), is it possible for pm_genpd_remove() to free the domain
memory while an external caller is still holding or mutating this stale
pointer?
[ ... ]
> @@ -2995,7 +2995,7 @@ int of_genpd_add_child_ids(struct device_node *np,
> goto err_unwind;
>
> /* Get the parent domain */
> - parent_genpd = genpd_get_from_provider(&parent_args);
> + parent_genpd = of_genpd_get_from_provider(&parent_args);
> of_node_put(parent_args.np);
> if (IS_ERR(parent_genpd)) {
> pr_err("Failed to get parent domain for %pOF: %ld\n",
[Severity: High]
Does this sequence present a Time-Of-Check to Time-Of-Use (TOCTOU) race?
Because of_genpd_get_from_provider() drops the lock before returning, there
is a window between retrieving parent_genpd and subsequently using it (such
as passing it to pm_genpd_add_subdomain() later in this function).
Could the parent domain be freed by a concurrent unregistration during this
window, before the necessary locks are acquired by the subsequent operation?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1788338320.git.geert+renesas@glider.be?part=5
next prev parent reply other threads:[~2026-09-02 11:40 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 11:29 [PATCH v3 00/12] R-Car X5H Ironhide CPG/MDLC SCMI remapping support Geert Uytterhoeven
2026-09-02 11:29 ` [PATCH v3 01/12] dt-bindings: clock: renesas,r8a78000-cpg: Add renesas,scmi-firmware property Geert Uytterhoeven
2026-09-02 11:29 ` [PATCH v3 02/12] dt-bindings: power: renesas,r8a78000-mdlc: Add firmware property Geert Uytterhoeven
2026-09-02 11:29 ` [PATCH v3 03/12] firmware: arm_scmi: Add scmi_get_base_info() Geert Uytterhoeven
2026-09-02 11:29 ` [PATCH v3 04/12] of: property: fw_devlink: Add support for renesas,scmi-firmware Geert Uytterhoeven
2026-09-02 11:29 ` [PATCH v3 05/12] pmdomain: Make genpd_get_from_provider() public Geert Uytterhoeven
2026-09-02 11:40 ` sashiko-bot [this message]
2026-09-02 11:29 ` [PATCH v3 06/12] reset: Extract __reset_control_get_from_provider() Geert Uytterhoeven
2026-09-03 8:55 ` Philipp Zabel
2026-09-02 11:29 ` [PATCH v3 07/12] reset: Add reset_control_get_from_provider_exclusive() Geert Uytterhoeven
2026-09-02 11:38 ` sashiko-bot
2026-09-02 11:44 ` Geert Uytterhoeven
2026-09-03 10:03 ` Philipp Zabel
2026-09-02 11:29 ` [PATCH v3 08/12] clk: renesas: r8a78000: Add clk_hw to clk_map Geert Uytterhoeven
2026-09-02 11:29 ` [PATCH v3 09/12] clk: renesas: r8a78000: Add SCMI remapping support Geert Uytterhoeven
2026-09-02 11:41 ` sashiko-bot
2026-09-02 11:29 ` [PATCH v3 10/12] pmdomain: " Geert Uytterhoeven
2026-09-02 11:47 ` sashiko-bot
2026-09-02 11:29 ` [PATCH v3 11/12] arm64: dts: renesas: ironhide: Enable SCMI devpd, sys, clock, and reset Geert Uytterhoeven
2026-09-02 11:29 ` [PATCH v3 12/12] arm64: dts: renesas: ironhide: Add CPG/MDLC renesas,scmi-firmware properties Geert Uytterhoeven
2026-09-02 11:40 ` 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=20260902114044.8D0FA1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=linux-clk@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wsa+renesas@sang-engineering.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