All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Fan <peng.fan@oss.nxp.com>
To: Lee Jones <lee@kernel.org>
Cc: Abel Vesa <abelvesa@kernel.org>, Peng Fan <peng.fan@nxp.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Brian Masney <bmasney+clk@redhat.com>,
	Jerome Brunet <jbrunet+clk@baylibre.com>,
	Frank Li <Frank.Li@nxp.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	Pengpeng Hou <pengpeng@iscas.ac.cn>,
	Dong Aisheng <aisheng.dong@nxp.com>,
	Shawn Guo <shawnguo@kernel.org>,
	linux-clk@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 01/10] clk: imx: imx8qxp-lpcg: Prevent stack overflow when parsing clocks
Date: Wed, 25 Nov 2026 08:19:27 +0800	[thread overview]
Message-ID: <awYpjwvlR+VvYnyf@shlinux89> (raw)
In-Reply-To: <20261123164834.3330320-2-lee@kernel.org>

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>

There was already a fix from Abel.

https://lore.kernel.org/linux-clk/20261102-imx8qxp-lpcg-duplicate-clock-indices-v1-2-1c3fc3fe727c@oss.qualcomm.com/

Regards,
Peng

>---
> 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
>
>

  parent reply	other threads:[~2026-11-25  0:14 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 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-25  0:19   ` Peng Fan [this message]
2026-11-23 16:47 ` [PATCH 02/10] clk: lmk04832: Validate child reg index in lmk04832_probe() Lee Jones
2026-11-23 16:47 ` [PATCH 03/10] clk: tegra: bpmp: Bound num_parents by MRQ_CLK_MAX_PARENTS Lee Jones
2026-11-23 16:47 ` [PATCH 04/10] clk: composite: Initialise sub-hw pointers in determine_rate() Lee Jones
2026-11-23 16:47 ` [PATCH 05/10] clk: divider: Avoid division by zero in _div_round_closest() Lee Jones
2026-11-23 17:13   ` sashiko-bot
2026-11-24 17:36   ` Brian Masney
2026-11-26  8:25     ` Lee Jones
2026-11-23 16:47 ` [PATCH 06/10] clk: gpio: Reject gate clocks with multiple parents Lee Jones
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
2026-11-24 13:14     ` Lee Jones
2026-11-25 20:59   ` Peter Griffin
2026-11-26  7:09   ` Krzysztof Kozlowski
2026-11-26  7:11     ` Krzysztof Kozlowski
2026-11-23 16:47 ` [PATCH 08/10] clk: tenstorrent: Poll atomically in atlantis_clk_pll_enable() Lee Jones
2026-11-23 16:47   ` Lee Jones
2026-11-23 19:23   ` Anirudh Srinivasan
2026-11-23 19:23     ` Anirudh Srinivasan
2026-11-24 18:31   ` Brian Masney
2026-11-24 18:31     ` Brian Masney
2026-11-26  8:24     ` Lee Jones
2026-11-26  8:24       ` Lee Jones
2026-11-23 16:47 ` [PATCH 09/10] clk: cdce925: Use devm_of_clk_add_hw_provider() to avoid UAF on unbind Lee Jones
2026-11-23 16:47 ` [PATCH 10/10] clk: mmp: audio: Use devm_of_clk_add_hw_provider() to prevent UAF Lee Jones
2026-11-24 18:59 ` (subset) [PATCH 00/10] clk: Assorted bug fixes across clock core and drivers Brian Masney
2026-11-24 18:59   ` Brian Masney
2026-11-26  7:14 ` Krzysztof Kozlowski
2026-11-26  7:14   ` Krzysztof Kozlowski

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=awYpjwvlR+VvYnyf@shlinux89 \
    --to=peng.fan@oss.nxp.com \
    --cc=Frank.Li@nxp.com \
    --cc=abelvesa@kernel.org \
    --cc=aisheng.dong@nxp.com \
    --cc=bmasney+clk@redhat.com \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=jbrunet+clk@baylibre.com \
    --cc=kernel@pengutronix.de \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peng.fan@nxp.com \
    --cc=pengpeng@iscas.ac.cn \
    --cc=s.hauer@pengutronix.de \
    --cc=sboyd@kernel.org \
    --cc=shawnguo@kernel.org \
    --cc=stable@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.