From: Prasanna Kumar T S M <ptsm@linux.microsoft.com>
To: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>,
sboyd@kernel.org, bmasney+clk@redhat.com,
jbrunet+clk@baylibre.com, michal.simek@amd.com,
shubhrajyoti.datta@amd.com
Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
git@amd.com, Beesam Sridhar Sagar <sagar.beesamsridhar@amd.com>
Subject: Re: [PATCH 3/3] clk: zynqmp: Fix unchecked type index into clock topology tables
Date: Tue, 1 Dec 2026 18:51:41 +0530 [thread overview]
Message-ID: <81d11ef1-87e5-4396-acfe-adeb9196a4ed@linux.microsoft.com> (raw)
In-Reply-To: <20261201064353.238312-4-radhey.shyam.pandey@amd.com>
On 01-12-2026 12:13, Radhey Shyam Pandey wrote:
> From: Beesam Sridhar Sagar <sagar.beesamsridhar@amd.com>
>
> The topology 'type' value received from firmware is stored without
> validation and later used as an index into the clk_topology[]
> function-pointer table and clk_type_postfix[] string table in
> zynqmp_register_clk_topology().
>
> CLK_TOPOLOGY_TYPE is a 4-bit field, allowing values in the range
> 0..15, while enum topology_type and the corresponding tables contain
> only 7 entries. Values outside the valid range can therefore lead to
> out-of-bounds accesses, including a function-pointer dereference.
>
> Validate the topology type while parsing the firmware response and
> return an error when an invalid value is detected.
>
> Fixes: 3fde0e16d016 ("drivers: clk: Add ZynqMP clock driver")
> Signed-off-by: Beesam Sridhar Sagar <sagar.beesamsridhar@amd.com>
> Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
> ---
> drivers/clk/zynqmp/clkc.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c
> index 5d827b2bb0ad..4ce376023d7f 100644
> --- a/drivers/clk/zynqmp/clkc.c
> +++ b/drivers/clk/zynqmp/clkc.c
> @@ -418,6 +418,8 @@ static int __zynqmp_clock_get_topology(struct clock_topology *topology,
> type = FIELD_GET(CLK_TOPOLOGY_TYPE, response->topology[i]);
> if (type == TYPE_INVALID)
> return END_OF_TOPOLOGY_NODE;
> + if (type >= ARRAY_SIZE(clk_topology))
> + return -EINVAL;
> topology[*nnodes].type = type;
> topology[*nnodes].flag = FIELD_GET(CLK_TOPOLOGY_FLAGS,
> response->topology[i]);
> @@ -459,6 +461,8 @@ static int zynqmp_clock_get_topology(u32 clk_id,
> num_nodes);
> if (ret == END_OF_TOPOLOGY_NODE)
> return 0;
> + if (ret < 0)
> + return ret;
> }
>
> return 0;
Looks good.
Reviewed-by: Prasanna Kumar T S M <ptsm@linux.microsoft.com>
prev parent reply other threads:[~2026-12-01 13:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 6:43 [PATCH 0/3] clk: zynqmp: fix out-of-bounds accesses in firmware clock parsing Radhey Shyam Pandey
2026-12-01 6:43 ` [PATCH 1/3] clk: zynqmp: Fix off-by-one loop bound in zynqmp_clock_get_topology() Radhey Shyam Pandey
2026-12-01 13:21 ` Prasanna Kumar T S M
2026-12-01 6:43 ` [PATCH 2/3] clk: zynqmp: Fix unbounded parent array overflow in clock parent lookup Radhey Shyam Pandey
2026-12-01 13:34 ` Prasanna Kumar T S M
2026-12-01 6:43 ` [PATCH 3/3] clk: zynqmp: Fix unchecked type index into clock topology tables Radhey Shyam Pandey
2026-12-01 6:54 ` sashiko-bot
2026-12-01 13:21 ` Prasanna Kumar T S M [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=81d11ef1-87e5-4396-acfe-adeb9196a4ed@linux.microsoft.com \
--to=ptsm@linux.microsoft.com \
--cc=bmasney+clk@redhat.com \
--cc=git@amd.com \
--cc=jbrunet+clk@baylibre.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=radhey.shyam.pandey@amd.com \
--cc=sagar.beesamsridhar@amd.com \
--cc=sboyd@kernel.org \
--cc=shubhrajyoti.datta@amd.com \
/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.