All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org,
	linux-clk@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v11 6/6] clk: scmi: Add i.MX95 OEM extension support for SCMI clock driver
Date: Mon, 17 Aug 2026 11:16:16 +0000	[thread overview]
Message-ID: <20260817111616.AC02E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260817-clk-v11-v11-6-36e9bc701b11@nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Out-of-bounds read on `hws` array due to missing bounds check on firmware-supplied parent indices.
--

--- Patch [6]: [PATCH v11 6/6] clk: scmi: Add i.MX95 OEM extension support for SCMI clock driver ---
commit d5aa65b1d50040a18c4b3cc2d72d625cca785922
Author: Peng Fan <peng.fan@nxp.com>

clk: scmi: Add i.MX95 OEM extension support for SCMI clock driver
    
This commit introduces OEM extension support for the SCMI clock driver to
allow vendor-specific features like spread spectrum configuration. It adds
a new file clk-scmi-oem.c, initializes the extensions via scmi_clk_oem_init(),
and passes the scmi_device to scmi_clk_ops_select() for OEM data access.

> diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c
> index d88e78cc9a12e..2dd50c5b4ea8f 100644
> --- a/drivers/clk/clk-scmi.c
> +++ b/drivers/clk/clk-scmi.c

[ ... ]

> @@ -406,7 +419,7 @@ static int scmi_clocks_probe(struct scmi_device *sdev)
>  		 * to avoid sharing the devm_ allocated clk_ops between multiple
>  		 * SCMI clk driver instances.
>  		 */
> -		scmi_ops = scmi_clk_ops_select(sclk, transport_is_atomic,
> +		scmi_ops = scmi_clk_ops_select(sdev, sclk, transport_is_atomic,
>  					       atomic_threshold_us,
>  					       scmi_clk_ops_db,
>  					       ARRAY_SIZE(scmi_clk_ops_db));

[Severity: High]
This is a pre-existing issue, but does this function lack bounds checking on
the firmware-supplied parent indices?

In scmi_clocks_probe(), the total number of clocks is retrieved from the SCMI
firmware, and the hws array is allocated to that size. During clock
initialization, the firmware is queried for possible parent clocks:

	if (sclk->info->num_parents > 0) {
		sclk->parent_data = devm_kcalloc(dev, sclk->info->num_parents,
						 sizeof(*sclk->parent_data), GFP_KERNEL);
		if (!sclk->parent_data)
			return -ENOMEM;

		for (int i = 0; i < sclk->info->num_parents; i++) {
			sclk->parent_data[i].index = sclk->info->parents[i];
			sclk->parent_data[i].hw = hws[sclk->info->parents[i]];
		}
	}

If the firmware returns a parent clock identifier (sclk->info->parents[i])
that is greater than or equal to the clock count, wouldn't the driver use it
without validation as an array index into the hws array?

Could this lead to an out-of-bounds memory read and a kernel crash when the
clock framework later dereferences the invalid pointer?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260817-clk-v11-v11-0-36e9bc701b11@nxp.com?part=6

      reply	other threads:[~2026-08-17 11:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17 10:59 [PATCH v11 0/6] clk: Support spread spectrum and use it in clk-scmi Peng Fan (OSS)
2026-08-17 10:59 ` [PATCH v11 1/6] dt-bindings: clock: Add spread spectrum definition Peng Fan (OSS)
2026-08-17 10:59 ` [PATCH v11 2/6] clk: Introduce clk_hw_set_spread_spectrum Peng Fan (OSS)
2026-08-17 11:04   ` sashiko-bot
2026-08-17 10:59 ` [PATCH v11 3/6] clk: conf: Support assigned-clock-sscs Peng Fan (OSS)
2026-08-17 11:04   ` sashiko-bot
2026-08-17 10:59 ` [PATCH v11 4/6] clk: Add KUnit tests for assigned-clock-sscs Peng Fan (OSS)
2026-08-17 11:07   ` sashiko-bot
2026-08-17 10:59 ` [PATCH v11 5/6] clk: scmi: Introduce common header for SCMI clock interface Peng Fan (OSS)
2026-08-17 11:08   ` sashiko-bot
2026-08-17 10:59 ` [PATCH v11 6/6] clk: scmi: Add i.MX95 OEM extension support for SCMI clock driver Peng Fan (OSS)
2026-08-17 11:16   ` sashiko-bot [this message]

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=20260817111616.AC02E1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=peng.fan@oss.nxp.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.