Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
* [PATCH 00/10] clk: Assorted bug fixes across clock core and drivers
@ 2026-11-23 16:47 Lee Jones
  2026-11-23 16:47 ` [PATCH 01/10] clk: imx: imx8qxp-lpcg: Prevent stack overflow when parsing clocks Lee Jones
  0 siblings, 1 reply; 3+ messages in thread
From: Lee Jones @ 2026-11-23 16:47 UTC (permalink / raw)
  To: lee, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	linux-riscv
  Cc: linux-kernel, Uwe Kleine-König, Zhao, Linaro, Abel Vesa,
	Alim Akhtar, Amit Daniel Kachhap, Anirudh Srinivasan,
	Brian Masney, Chander Kashyap, Chanwoo Choi, Dong Aisheng,
	Drew Fustini, Fabio Estevam, Francesco Dolcini, Frank Li,
	Heiko Stuebner, imx, Jerome Brunet, Joel Stanley, Jonathan Hunter,
	Jyri Sarha, Krzysztof Kozlowski, Lad Prabhakar, Liam Beguin,
	Linaro Ltd, linux-arm-kernel, linux-clk, linux-samsung-soc,
	linux-tegra, Lubomir Rintel, Lukasz Luba, Marian Mihailescu,
	Maxime Coquelin, Mike Looijmans, Peng Fan, Pengpeng Hou,
	Pengutronix Kernel Team, Peter Griffin, Prashant Gaikwad,
	Rosen Penev, Sascha Hauer, Sergej Sawazki, Shawn Guo,
	Stephen Boyd, Sylwester Nawrocki, Thierry Reding, Thomas Abraham,
	Tomasz Figa

These issues were reported by Sashiko.

None of these changes have been tested on physical hardware.

Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: "Zhao, Linaro" <richard.zhao@linaro.org>
Cc: Abel Vesa <abelvesa@kernel.org>
Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Amit Daniel Kachhap <amit.daniel@samsung.com>
Cc: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
Cc: Brian Masney <bmasney+clk@redhat.com>
Cc: Chander Kashyap <k.chander@samsung.com>
Cc: Chanwoo Choi <cw00.choi@samsung.com>
Cc: Dong Aisheng <aisheng.dong@nxp.com>
Cc: Drew Fustini <fustini@kernel.org>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Francesco Dolcini <francesco.dolcini@toradex.com>
Cc: Frank Li <Frank.Li@nxp.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: imx@lists.linux.dev
Cc: Jerome Brunet <jbrunet+clk@baylibre.com>
Cc: Joel Stanley <jms@oss.tenstorrent.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Jyri Sarha <jsarha@ti.com>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Cc: Liam Beguin <lvb@xiphos.com>
Cc: Linaro Ltd <mturquette@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-clk@vger.kernel.org
Cc: linux-riscv@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-tegra@vger.kernel.org
Cc: Lubomir Rintel <lkundrak@v3.sk>
Cc: Lukasz Luba <lukasz.luba@arm.com>
Cc: Marian Mihailescu <mihailescu2m@gmail.com>
Cc: Maxime Coquelin <maxime.coquelin@st.com>
Cc: Mike Looijmans <mike.looijmans@topic.nl>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Pengpeng Hou <pengpeng@iscas.ac.cn>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Peter Griffin <peter.griffin@linaro.org>
Cc: Prashant Gaikwad <pgaikwad@nvidia.com>
Cc: Rosen Penev <rosenp@gmail.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Sergej Sawazki <ce3a@gmx.de>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
Cc: Thierry Reding <thierry.reding@kernel.org>
Cc: Thomas Abraham <thomas.ab@samsung.com>
Cc: Tomasz Figa <t.figa@samsung.com>

Lee Jones (10):
  clk: imx: imx8qxp-lpcg: Prevent stack overflow when parsing clocks
  clk: lmk04832: Validate child reg index in lmk04832_probe()
  clk: tegra: bpmp: Bound num_parents by MRQ_CLK_MAX_PARENTS
  clk: composite: Initialise sub-hw pointers in determine_rate()
  clk: divider: Avoid division by zero in _div_round_closest()
  clk: gpio: Reject gate clocks with multiple parents
  clk: samsung: exynos5420: Terminate PLL rate tables with sentinels
  clk: tenstorrent: Poll atomically in atlantis_clk_pll_enable()
  clk: cdce925: Use devm_of_clk_add_hw_provider() to avoid UAF on unbind
  clk: mmp: audio: Use devm_of_clk_add_hw_provider() to prevent UAF

 drivers/clk/clk-cdce925.c               |  4 ++--
 drivers/clk/clk-composite.c             |  2 ++
 drivers/clk/clk-divider.c               |  3 +++
 drivers/clk/clk-gpio.c                  |  3 +++
 drivers/clk/clk-lmk04832.c              | 10 ++++++++--
 drivers/clk/imx/clk-imx8qxp-lpcg.c      |  4 ++++
 drivers/clk/mmp/clk-audio.c             |  4 ++--
 drivers/clk/samsung/clk-exynos5420.c    |  4 ++++
 drivers/clk/tegra/clk-bpmp.c            | 14 +++++++-------
 drivers/clk/tenstorrent/atlantis-prcm.c |  9 +++++----
 10 files changed, 40 insertions(+), 17 deletions(-)

-- 
2.56.1.750.gf70dc682cf-goog


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

* [PATCH 01/10] clk: imx: imx8qxp-lpcg: Prevent stack overflow when parsing clocks
  2026-11-23 16:47 [PATCH 00/10] clk: Assorted bug fixes across clock core and drivers Lee Jones
@ 2026-11-23 16:47 ` Lee Jones
  2026-11-23 17:25   ` Frank Li
  0 siblings, 1 reply; 3+ messages in thread
From: Lee Jones @ 2026-11-23 16:47 UTC (permalink / raw)
  To: lee, Abel Vesa, Peng Fan, Stephen Boyd, Brian Masney,
	Jerome Brunet, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, Pengpeng Hou, Dong Aisheng, Shawn Guo, linux-clk,
	imx, linux-arm-kernel, linux-kernel
  Cc: stable

imx_lpcg_parse_clks_from_dt() allocates output_names, parent_names, and
bit_offset on the stack with IMX_LPCG_MAX_CLKS (8) entries each to match
the hardware limit of eight clock outputs per LPCG block.  However, it
only checks whether of_property_count_u32_elems() returns a negative
error code and enforces no upper bound on count.

If a Device Tree node specifies more than IMX_LPCG_MAX_CLKS entries in
clock-indices, subsequent calls to of_property_read_u32_array(),
of_clk_parent_fill(), and of_property_read_string_array() write past the
end of these stack buffers.  Reject counts exceeding IMX_LPCG_MAX_CLKS.

Fixes: d5f1e6a2bb61 ("clk: imx: imx8qxp-lpcg: add parsing clocks from device tree")
Closes: https://sashiko.dev/#/bug/linux-22dfac78-f44b-42f8-985a-995308723fc4
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/clk/imx/clk-imx8qxp-lpcg.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/clk/imx/clk-imx8qxp-lpcg.c b/drivers/clk/imx/clk-imx8qxp-lpcg.c
index 9ad016106b1e..5eb4bdbaf7d8 100644
--- a/drivers/clk/imx/clk-imx8qxp-lpcg.c
+++ b/drivers/clk/imx/clk-imx8qxp-lpcg.c
@@ -199,6 +199,10 @@ static int imx_lpcg_parse_clks_from_dt(struct platform_device *pdev,
 		dev_err(&pdev->dev, "failed to count clocks\n");
 		return -EINVAL;
 	}
+	if (count > IMX_LPCG_MAX_CLKS) {
+		dev_err(&pdev->dev, "too many clocks: %d\n", count);
+		return -EINVAL;
+	}
 
 	/*
 	 * A trick here is that we set the num of clks to the MAX instead
-- 
2.56.1.750.gf70dc682cf-goog


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

* Re: [PATCH 01/10] clk: imx: imx8qxp-lpcg: Prevent stack overflow when parsing clocks
  2026-11-23 16:47 ` [PATCH 01/10] clk: imx: imx8qxp-lpcg: Prevent stack overflow when parsing clocks Lee Jones
@ 2026-11-23 17:25   ` Frank Li
  0 siblings, 0 replies; 3+ messages in thread
From: Frank Li @ 2026-11-23 17:25 UTC (permalink / raw)
  To: Lee Jones
  Cc: Abel Vesa, Peng Fan, Stephen Boyd, Brian Masney, Jerome Brunet,
	Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Pengpeng Hou, Dong Aisheng, Shawn Guo, linux-clk, imx,
	linux-arm-kernel, linux-kernel, stable

On Mon, Nov 23, 2026 at 04:47:34PM +0000, Lee Jones wrote:
> imx_lpcg_parse_clks_from_dt() allocates output_names, parent_names, and
> bit_offset on the stack with IMX_LPCG_MAX_CLKS (8) entries each to match
> the hardware limit of eight clock outputs per LPCG block.  However, it
> only checks whether of_property_count_u32_elems() returns a negative
> error code and enforces no upper bound on count.
>
> If a Device Tree node specifies more than IMX_LPCG_MAX_CLKS entries in
> clock-indices, subsequent calls to of_property_read_u32_array(),
> of_clk_parent_fill(), and of_property_read_string_array() write past the
> end of these stack buffers.  Reject counts exceeding IMX_LPCG_MAX_CLKS.
>
> Fixes: d5f1e6a2bb61 ("clk: imx: imx8qxp-lpcg: add parsing clocks from device tree")
> Closes: https://sashiko.dev/#/bug/linux-22dfac78-f44b-42f8-985a-995308723fc4
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  drivers/clk/imx/clk-imx8qxp-lpcg.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/clk/imx/clk-imx8qxp-lpcg.c b/drivers/clk/imx/clk-imx8qxp-lpcg.c
> index 9ad016106b1e..5eb4bdbaf7d8 100644
> --- a/drivers/clk/imx/clk-imx8qxp-lpcg.c
> +++ b/drivers/clk/imx/clk-imx8qxp-lpcg.c
> @@ -199,6 +199,10 @@ static int imx_lpcg_parse_clks_from_dt(struct platform_device *pdev,
>  		dev_err(&pdev->dev, "failed to count clocks\n");
>  		return -EINVAL;
>  	}
> +	if (count > IMX_LPCG_MAX_CLKS) {
> +		dev_err(&pdev->dev, "too many clocks: %d\n", count);
> +		return -EINVAL;
> +	}
>
>  	/*
>  	 * A trick here is that we set the num of clks to the MAX instead
> --
> 2.56.1.750.gf70dc682cf-goog
>
>

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

end of thread, other threads:[~2026-11-23 17:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 16:47 [PATCH 00/10] clk: Assorted bug fixes across clock core and drivers Lee Jones
2026-11-23 16:47 ` [PATCH 01/10] clk: imx: imx8qxp-lpcg: Prevent stack overflow when parsing clocks Lee Jones
2026-11-23 17:25   ` Frank Li

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