Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
* [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 01/10] clk: ti: fapll: Fix output clock array allocation and bounds check Lee Jones
  0 siblings, 1 reply; 2+ 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] 2+ messages in thread

* [PATCH 01/10] clk: ti: fapll: Fix output clock array allocation and bounds check
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2026-11-27 19:25 UTC (permalink / raw)
  To: lee, Tero Kristo, Stephen Boyd, Brian Masney, Jerome Brunet,
	Tony Lindgren, Michael Turquette, linux-omap, linux-clk,
	linux-kernel
  Cc: stable

ti_fapll_setup() allocates fd->outputs.clks as
sizeof(struct clk *) * MAX_FAPLL_OUTPUTS + 1, adding a single byte
rather than an extra pointer slot for the 1-based child synthesisers
stored at indices 1..MAX_FAPLL_OUTPUTS.  It also reads output_instance
into a signed int via of_property_read_u32_index() and indexes
fd->outputs.clks[output_instance] without bounds validation, allowing
out-of-bounds heap writes.

Allocate MAX_FAPLL_OUTPUTS + 1 pointer slots with kzalloc_objs(), store
output_instance as u32, and skip entries exceeding MAX_FAPLL_OUTPUTS.

Fixes: 163152cbbe32 ("clk: ti: Add support for FAPLL on dm816x")
Closes: https://sashiko.dev/#/bug/linux-48a97add-8ee5-49f5-b05c-925006d9ec42
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/clk/ti/fapll.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c
index 7d6a4dd4fc8c..d5e95e6489cd 100644
--- a/drivers/clk/ti/fapll.c
+++ b/drivers/clk/ti/fapll.c
@@ -549,9 +549,8 @@ static void __init ti_fapll_setup(struct device_node *node)
 	if (!fd)
 		return;
 
-	fd->outputs.clks = kzalloc(sizeof(struct clk *) *
-				   MAX_FAPLL_OUTPUTS + 1,
-				   GFP_KERNEL);
+	fd->outputs.clks = kzalloc_objs(*fd->outputs.clks,
+					MAX_FAPLL_OUTPUTS + 1);
 	if (!fd->outputs.clks)
 		goto free;
 
@@ -614,7 +613,7 @@ static void __init ti_fapll_setup(struct device_node *node)
 		const char *output_name;
 		void __iomem *freq, *div;
 		struct clk *synth_clk;
-		int output_instance;
+		u32 output_instance;
 		u32 v;
 
 		if (of_property_read_string_index(node, "clock-output-names",
@@ -625,6 +624,12 @@ static void __init ti_fapll_setup(struct device_node *node)
 					       &output_instance))
 			output_instance = i;
 
+		if (output_instance > MAX_FAPLL_OUTPUTS) {
+			pr_err("%pOFn invalid output_instance %u\n",
+			       node, output_instance);
+			continue;
+		}
+
 		freq = fd->base + (output_instance * 8);
 		div = freq + 4;
 
-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-27 19:26 UTC | newest]

Thread overview: 2+ 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 01/10] clk: ti: fapll: Fix output clock array allocation and bounds check Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox