* [PATCH 01/10] clk: imx: imx8qxp-lpcg: Prevent stack overflow when parsing clocks
[not found] <20261123164834.3330320-1-lee@kernel.org>
@ 2026-11-23 16:47 ` Lee Jones
2026-11-23 17:25 ` Frank Li
2026-11-23 16:47 ` [PATCH 07/10] clk: samsung: exynos5420: Terminate PLL rate tables with sentinels Lee Jones
1 sibling, 1 reply; 4+ 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] 4+ messages in thread
* [PATCH 07/10] clk: samsung: exynos5420: Terminate PLL rate tables with sentinels
[not found] <20261123164834.3330320-1-lee@kernel.org>
2026-11-23 16:47 ` [PATCH 01/10] clk: imx: imx8qxp-lpcg: Prevent stack overflow when parsing clocks Lee Jones
@ 2026-11-23 16:47 ` Lee Jones
2026-11-23 17:26 ` Krzysztof Kozlowski
1 sibling, 1 reply; 4+ messages in thread
From: Lee Jones @ 2026-11-23 16:47 UTC (permalink / raw)
To: lee, Krzysztof Kozlowski, Sylwester Nawrocki, Chanwoo Choi,
Peter Griffin, Alim Akhtar, Stephen Boyd, Brian Masney,
Jerome Brunet, Thomas Abraham, Chander Kashyap,
Amit Daniel Kachhap, Tomasz Figa, Lukasz Luba, Marian Mihailescu,
linux-samsung-soc, linux-clk, linux-arm-kernel, linux-kernel
Cc: stable
_samsung_clk_register_pll() sizes each PLL rate table by scanning until
it encounters an entry with .rate == 0, then copies the counted entries
into pll->rate_table. However, exynos5420_pll2550x_24mhz_tbl,
exynos5422_bpll_rate_table, exynos5420_epll_24mhz_tbl, and
exynos5420_vpll_24mhz_tbl all omit a terminating zero sentinel, causing
out-of-bounds reads into adjacent read-only data and populating
pll->rate_table with bogus entries.
Append a sentinel entry to each of the four PLL rate tables.
Fixes: ca5b40293822 ("clk: samsung: register exynos5420 apll/kpll configuration data")
Fixes: 9842452acd3d ("clk: samsung: exynos542x: Add EPLL rate table")
Fixes: 8b4a7acf7b30 ("clk: samsung: add BPLL rate table for Exynos 5422 SoC")
Fixes: b92981de92cb ("clk: samsung: exynos5420: Add VPLL rate table")
Closes: https://sashiko.dev/#/bug/linux-553831f9-0a7b-4e94-be60-222de60ca8c3
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/clk/samsung/clk-exynos5420.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/clk/samsung/clk-exynos5420.c b/drivers/clk/samsung/clk-exynos5420.c
index 400a5c59815c..35baeabf3ccb 100644
--- a/drivers/clk/samsung/clk-exynos5420.c
+++ b/drivers/clk/samsung/clk-exynos5420.c
@@ -1419,6 +1419,7 @@ static const struct samsung_pll_rate_table exynos5420_pll2550x_24mhz_tbl[] __ini
PLL_35XX_RATE(24 * MHZ, 400000000, 200, 3, 2),
PLL_35XX_RATE(24 * MHZ, 300000000, 200, 2, 3),
PLL_35XX_RATE(24 * MHZ, 200000000, 200, 3, 3),
+ { /* sentinel */ }
};
static const struct samsung_pll_rate_table exynos5422_bpll_rate_table[] = {
@@ -1430,6 +1431,7 @@ static const struct samsung_pll_rate_table exynos5422_bpll_rate_table[] = {
PLL_35XX_RATE(24 * MHZ, 275000000, 275, 3, 3),
PLL_35XX_RATE(24 * MHZ, 206000000, 206, 3, 3),
PLL_35XX_RATE(24 * MHZ, 165000000, 110, 2, 3),
+ { /* sentinel */ }
};
static const struct samsung_pll_rate_table exynos5420_epll_24mhz_tbl[] = {
@@ -1448,6 +1450,7 @@ static const struct samsung_pll_rate_table exynos5420_epll_24mhz_tbl[] = {
PLL_36XX_RATE(24 * MHZ, 49152000U, 197, 3, 5, -25690),
PLL_36XX_RATE(24 * MHZ, 45158401U, 90, 3, 4, 20762),
PLL_36XX_RATE(24 * MHZ, 32768001U, 131, 3, 5, 4719),
+ { /* sentinel */ }
};
static const struct samsung_pll_rate_table exynos5420_vpll_24mhz_tbl[] = {
@@ -1459,6 +1462,7 @@ static const struct samsung_pll_rate_table exynos5420_vpll_24mhz_tbl[] = {
PLL_35XX_RATE(24 * MHZ, 266000000U, 266, 3, 3),
PLL_35XX_RATE(24 * MHZ, 177000000U, 118, 2, 3),
PLL_35XX_RATE(24 * MHZ, 100000000U, 200, 3, 4),
+ { /* sentinel */ }
};
static struct samsung_pll_clock exynos5x_plls[nr_plls] __initdata = {
--
2.56.1.750.gf70dc682cf-goog
^ permalink raw reply related [flat|nested] 4+ 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; 4+ 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] 4+ messages in thread
* Re: [PATCH 07/10] clk: samsung: exynos5420: Terminate PLL rate tables with sentinels
2026-11-23 16:47 ` [PATCH 07/10] clk: samsung: exynos5420: Terminate PLL rate tables with sentinels Lee Jones
@ 2026-11-23 17:26 ` Krzysztof Kozlowski
0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2026-11-23 17:26 UTC (permalink / raw)
To: Lee Jones, Sylwester Nawrocki, Chanwoo Choi, Peter Griffin,
Alim Akhtar, Stephen Boyd, Brian Masney, Jerome Brunet,
Thomas Abraham, Chander Kashyap, Amit Daniel Kachhap, Tomasz Figa,
Lukasz Luba, Marian Mihailescu, linux-samsung-soc, linux-clk,
linux-arm-kernel, linux-kernel
Cc: stable
On 23/11/2026 17:47, Lee Jones wrote:
> _samsung_clk_register_pll() sizes each PLL rate table by scanning until
> it encounters an entry with .rate == 0, then copies the counted entries
> into pll->rate_table. However, exynos5420_pll2550x_24mhz_tbl,
> exynos5422_bpll_rate_table, exynos5420_epll_24mhz_tbl, and
> exynos5420_vpll_24mhz_tbl all omit a terminating zero sentinel, causing
> out-of-bounds reads into adjacent read-only data and populating
> pll->rate_table with bogus entries.
>
> Append a sentinel entry to each of the four PLL rate tables.
>
> Fixes: ca5b40293822 ("clk: samsung: register exynos5420 apll/kpll configuration data")
> Fixes: 9842452acd3d ("clk: samsung: exynos542x: Add EPLL rate table")
> Fixes: 8b4a7acf7b30 ("clk: samsung: add BPLL rate table for Exynos 5422 SoC")
> Fixes: b92981de92cb ("clk: samsung: exynos5420: Add VPLL rate table")
> Closes: https://sashiko.dev/#/bug/linux-553831f9-0a7b-4e94-be60-222de60ca8c3
Also drivers/clk/samsung/clk-artpec8.c, artpec9, exynos5410,
clk-exynos7885.c and probably others?
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-23 17:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261123164834.3330320-1-lee@kernel.org>
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
2026-11-23 16:47 ` [PATCH 07/10] clk: samsung: exynos5420: Terminate PLL rate tables with sentinels Lee Jones
2026-11-23 17:26 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox