* [PATCH 00/10] clk: Fix OOB writes, UAFs, ERR_PTR dereferences, and rate-calc bugs (batch 2)
@ 2026-11-27 19:25 Lee Jones
2026-11-27 19:25 ` [PATCH 05/10] clk: rockchip: cpu: Allocate rate_table before registering notifier Lee Jones
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Lee Jones @ 2026-11-27 19:25 UTC (permalink / raw)
To: lee, Heiko Stuebner, linux-arm-kernel, linux-rockchip
Cc: linux-kernel, Thomas Richard (TI), Andrea della Porta,
Brian Masney, Conor Dooley, Dominique Belhachemi, Doug Anderson,
Emil Renner Berthing, Florian Fainelli, Hal Feng, Jerome Brunet,
Jonathan Hunter, Joshua Peisach, Linus Walleij, linux-clk,
linux-omap, linux-tegra, Michael Turquette, Michal Wilczynski,
Naushir Patuck, Nishanth Menon, Palmer Dabbelt, Prashant Gaikwad,
Rob Herring, Rosen Penev, Santosh Shilimkar, Stephen Boyd,
Tero Kristo, Thierry Reding, Thomas Abraham, Timo Alho,
Tony Lindgren, Wentao Liang, Xingyu Wu
These issues were reported by Sashiko.
This is batch 2 of Common Clock Framework fixes, based on clk/clk-next.
It addresses output array OOB writes in ti/fapll, ERR_PTR dereferences
and double-unregister in tegra/bpmp, notifier UAFs and global array
mutation in starfive/jh7110 and rockchip/cpu, rate and parent lookup
bugs in rp1, and allocation error handling in sci-clk and icst.
Cc: "Thomas Richard (TI)" <thomas.richard@bootlin.com>
Cc: Andrea della Porta <andrea.porta@suse.com>
Cc: Brian Masney <bmasney+clk@redhat.com>
Cc: Conor Dooley <conor.dooley@microchip.com>
Cc: Dominique Belhachemi <db@domibel.de>
Cc: Doug Anderson <dianders@chromium.org>
Cc: Emil Renner Berthing <kernel@esmil.dk>
Cc: Florian Fainelli <florian.fainelli@broadcom.com>
Cc: Hal Feng <hal.feng@starfivetech.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Jerome Brunet <jbrunet+clk@baylibre.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Joshua Peisach <jpeisach@ubuntu.com>
Cc: Linus Walleij <linusw@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-clk@vger.kernel.org
Cc: linux-omap@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-tegra@vger.kernel.org
Cc: Michael Turquette <mturquette@linaro.org>
Cc: Michal Wilczynski <m.wilczynski@samsung.com>
Cc: Naushir Patuck <naush@raspberrypi.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Palmer Dabbelt <palmer@rivosinc.com>
Cc: Prashant Gaikwad <pgaikwad@nvidia.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Rosen Penev <rosenp@gmail.com>
Cc: Santosh Shilimkar <ssantosh@kernel.org>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Tero Kristo <kristo@kernel.org>
Cc: Thierry Reding <thierry.reding@kernel.org>
Cc: Thomas Abraham <thomas.ab@samsung.com>
Cc: Timo Alho <talho@nvidia.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Wentao Liang <vulab@iscas.ac.cn>
Cc: Xingyu Wu <xingyu.wu@starfivetech.com>
Lee Jones (10):
clk: ti: fapll: Fix output clock array allocation and bounds check
clk: tegra: bpmp: Drop manual clock unregister on provider failure
clk: starfive: jh7110-sys: Use devres for PLL0 clock and notifier
clk: starfive: jh7110: Duplicate top clock bulk arrays per device
clk: rockchip: cpu: Allocate rate_table before registering notifier
clk: tegra: bpmp: Skip ERR_PTR entries in tegra_bpmp_clk_of_xlate()
clk: rp1: Propagate determine_rate() return value for PLL dividers
clk: rp1: Reference secondary PLL divider clk_hw in parent tables
clk: keystone: sci-clk: Check allocation failure before copying clock
array
clk: versatile: icst: Check kasprintf() and put parent node on error
drivers/clk/clk-rp1.c | 32 +++++++++----------
drivers/clk/keystone/sci-clk.c | 8 +++--
drivers/clk/rockchip/clk-cpu.c | 26 +++++++--------
.../clk/starfive/clk-starfive-jh7110-isp.c | 9 ++++--
.../clk/starfive/clk-starfive-jh7110-sys.c | 5 +--
.../clk/starfive/clk-starfive-jh7110-vout.c | 9 ++++--
drivers/clk/tegra/clk-bpmp.c | 14 +-------
drivers/clk/ti/fapll.c | 13 +++++---
drivers/clk/versatile/clk-icst.c | 5 +++
9 files changed, 66 insertions(+), 55 deletions(-)
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 05/10] clk: rockchip: cpu: Allocate rate_table before registering notifier
2026-11-27 19:25 [PATCH 00/10] clk: Fix OOB writes, UAFs, ERR_PTR dereferences, and rate-calc bugs (batch 2) Lee Jones
@ 2026-11-27 19:25 ` Lee Jones
2026-11-27 19:25 ` [PATCH 09/10] clk: keystone: sci-clk: Check allocation failure before copying clock array Lee Jones
2026-11-27 19:25 ` [PATCH 10/10] clk: versatile: icst: Check kasprintf() and put parent node on error Lee Jones
2 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2026-11-27 19:25 UTC (permalink / raw)
To: lee, Stephen Boyd, Brian Masney, Jerome Brunet, Heiko Stuebner,
Thomas Abraham, Doug Anderson, linux-clk, linux-arm-kernel,
linux-rockchip, linux-kernel
Cc: stable
rockchip_clk_register_cpuclk() registers cpuclk->clk_nb before
allocating cpuclk->rate_table, and on clk_register() failure frees
cpuclk->rate_table before unregistering the notifier. A concurrent
parent rate change can therefore observe a NULL rate_table while
rate_count is already non-zero, or dereference the freed rate_table
before clk_notifier_unregister() completes.
Allocate and populate cpuclk->rate_table before calling
clk_notifier_register(), and reverse the error-path teardown so the
notifier is unregistered before cpuclk->rate_table is freed.
Fixes: f6fba5f6967d ("clk: rockchip: add new clock-type for the cpuclk")
Closes: https://sashiko.dev/#/bug/linux-c0f18cf6-69e2-4cc3-8b2b-7b25245ccd06
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/clk/rockchip/clk-cpu.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/clk/rockchip/clk-cpu.c b/drivers/clk/rockchip/clk-cpu.c
index eb6b8b878e4d..27d5b6f6987d 100644
--- a/drivers/clk/rockchip/clk-cpu.c
+++ b/drivers/clk/rockchip/clk-cpu.c
@@ -360,36 +360,36 @@ struct clk *rockchip_clk_register_cpuclk(const char *name,
goto free_alt_parent;
}
- ret = clk_notifier_register(clk, &cpuclk->clk_nb);
- if (ret) {
- pr_err("%s: failed to register clock notifier for %s\n",
- __func__, name);
- goto free_alt_parent;
- }
-
if (nrates > 0) {
- cpuclk->rate_count = nrates;
cpuclk->rate_table = kmemdup_array(rates, nrates, sizeof(*rates),
GFP_KERNEL);
if (!cpuclk->rate_table) {
ret = -ENOMEM;
- goto unregister_notifier;
+ goto free_alt_parent;
}
+ cpuclk->rate_count = nrates;
+ }
+
+ ret = clk_notifier_register(clk, &cpuclk->clk_nb);
+ if (ret) {
+ pr_err("%s: failed to register clock notifier for %s\n",
+ __func__, name);
+ goto free_rate_table;
}
cclk = clk_register(NULL, &cpuclk->hw);
if (IS_ERR(cclk)) {
- pr_err("%s: could not register cpuclk %s\n", __func__, name);
+ pr_err("%s: could not register cpuclk %s\n", __func__, name);
ret = PTR_ERR(cclk);
- goto free_rate_table;
+ goto unregister_notifier;
}
return cclk;
-free_rate_table:
- kfree(cpuclk->rate_table);
unregister_notifier:
clk_notifier_unregister(clk, &cpuclk->clk_nb);
+free_rate_table:
+ kfree(cpuclk->rate_table);
free_alt_parent:
clk_disable_unprepare(cpuclk->alt_parent);
free_cpuclk:
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 09/10] clk: keystone: sci-clk: Check allocation failure before copying clock array
2026-11-27 19:25 [PATCH 00/10] clk: Fix OOB writes, UAFs, ERR_PTR dereferences, and rate-calc bugs (batch 2) Lee Jones
2026-11-27 19:25 ` [PATCH 05/10] clk: rockchip: cpu: Allocate rate_table before registering notifier Lee Jones
@ 2026-11-27 19:25 ` Lee Jones
2026-11-27 19:25 ` [PATCH 10/10] clk: versatile: icst: Check kasprintf() and put parent node on error Lee Jones
2 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2026-11-27 19:25 UTC (permalink / raw)
To: lee, Nishanth Menon, Tero Kristo, Santosh Shilimkar, Stephen Boyd,
Brian Masney, Jerome Brunet, Thomas Richard (TI),
linux-arm-kernel, linux-kernel, linux-clk
Cc: stable
ti_sci_scan_clocks_from_fw() calls devm_kmalloc_objs() without checking
for NULL before passing tmp_clks into memcpy(), and invokes memcpy()
with a NULL source pointer on the initial iteration when max_clks is
zero.
Return -ENOMEM if devm_kmalloc_objs() fails, and only copy and free the
previous array when max_clks is non-zero.
Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks")
Closes: https://sashiko.dev/#/bug/linux-4e2ecf16-17f1-4188-880c-c714a1bf588c
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/clk/keystone/sci-clk.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c
index 967f77900358..4cb1299cd49e 100644
--- a/drivers/clk/keystone/sci-clk.c
+++ b/drivers/clk/keystone/sci-clk.c
@@ -495,9 +495,13 @@ static int ti_sci_scan_clocks_from_fw(struct sci_clk_provider *provider)
if (num_clks == max_clks) {
tmp_clks = devm_kmalloc_objs(dev, sci_clk,
max_clks + 64);
- memcpy(tmp_clks, clks, max_clks * sizeof(sci_clk));
- if (max_clks)
+ if (!tmp_clks)
+ return -ENOMEM;
+ if (max_clks) {
+ memcpy(tmp_clks, clks,
+ max_clks * sizeof(sci_clk));
devm_kfree(dev, clks);
+ }
max_clks += 64;
clks = tmp_clks;
}
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 10/10] clk: versatile: icst: Check kasprintf() and put parent node on error
2026-11-27 19:25 [PATCH 00/10] clk: Fix OOB writes, UAFs, ERR_PTR dereferences, and rate-calc bugs (batch 2) Lee Jones
2026-11-27 19:25 ` [PATCH 05/10] clk: rockchip: cpu: Allocate rate_table before registering notifier Lee Jones
2026-11-27 19:25 ` [PATCH 09/10] clk: keystone: sci-clk: Check allocation failure before copying clock array Lee Jones
@ 2026-11-27 19:25 ` Lee Jones
2 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2026-11-27 19:25 UTC (permalink / raw)
To: lee, Linus Walleij, Stephen Boyd, Brian Masney, Jerome Brunet,
Rob Herring, linux-arm-kernel, linux-clk, linux-kernel
Cc: stable
of_syscon_icst_setup() does not check the return value of kasprintf()
before passing name into icst_clk_setup(), causing registration to fail
with -ENOMEM after redundant allocations and logging a NULL name while
leaking the parent device node reference. The IS_ERR(regclk) error path
also omits of_node_put().
Release the parent node and return early when kasprintf() fails, and
release the parent node when icst_clk_setup() returns an error.
Fixes: 1b2189f3aa50 ("clk: versatile: clk-icst: Ensure clock names are unique")
Fixes: d430819d69a5 ("clk: versatile-icst: add device tree support")
Closes: https://sashiko.dev/#/bug/linux-e1f9fcba-856e-41f5-ba69-bf159007e2af
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/clk/versatile/clk-icst.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/clk/versatile/clk-icst.c b/drivers/clk/versatile/clk-icst.c
index e9c7353aa5d5..10cb34a3e8ea 100644
--- a/drivers/clk/versatile/clk-icst.c
+++ b/drivers/clk/versatile/clk-icst.c
@@ -566,11 +566,16 @@ static void __init of_syscon_icst_setup(struct device_node *np)
/* Parent clock name is not the same as node parent */
parent_name = of_clk_get_parent_name(np, 0);
name = kasprintf(GFP_KERNEL, "%pOFP", np);
+ if (!name) {
+ of_node_put(parent);
+ return;
+ }
regclk = icst_clk_setup(NULL, &icst_desc, name, parent_name, map, ctype);
if (IS_ERR(regclk)) {
pr_err("error setting up syscon ICST clock %s\n", name);
kfree(name);
+ of_node_put(parent);
return;
}
of_clk_add_provider(np, of_clk_src_simple_get, regclk);
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-27 19:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 19:25 [PATCH 00/10] clk: Fix OOB writes, UAFs, ERR_PTR dereferences, and rate-calc bugs (batch 2) Lee Jones
2026-11-27 19:25 ` [PATCH 05/10] clk: rockchip: cpu: Allocate rate_table before registering notifier Lee Jones
2026-11-27 19:25 ` [PATCH 09/10] clk: keystone: sci-clk: Check allocation failure before copying clock array Lee Jones
2026-11-27 19:25 ` [PATCH 10/10] clk: versatile: icst: Check kasprintf() and put parent node on error Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox