* [PATCH v3] clk: imx: Fix an out-of-bounds access in dispmix_csr_clk_dev_data
@ 2025-06-19 6:21 Xiaolei Wang
2025-06-20 0:29 ` Peng Fan
2025-06-20 0:38 ` Stephen Boyd
0 siblings, 2 replies; 3+ messages in thread
From: Xiaolei Wang @ 2025-06-19 6:21 UTC (permalink / raw)
To: abelvesa, Frank.li, peng.fan, mturquette, sboyd, shawnguo,
s.hauer, kernel, festevam
Cc: linux-clk, imx, linux-arm-kernel, linux-kernel
When num_parents is 4, __clk_register() occurs an out-of-bounds
when accessing parent_names member. Use ARRAY_SIZE() instead of
hardcode number here.
BUG: KASAN: global-out-of-bounds in __clk_register+0x1844/0x20d8
Read of size 8 at addr ffff800086988e78 by task kworker/u24:3/59
Hardware name: NXP i.MX95 19X19 board (DT)
Workqueue: events_unbound deferred_probe_work_func
Call trace:
dump_backtrace+0x94/0xec
show_stack+0x18/0x24
dump_stack_lvl+0x8c/0xcc
print_report+0x398/0x5fc
kasan_report+0xd4/0x114
__asan_report_load8_noabort+0x20/0x2c
__clk_register+0x1844/0x20d8
clk_hw_register+0x44/0x110
__clk_hw_register_mux+0x284/0x3a8
imx95_bc_probe+0x4f4/0xa70
Fixes: 5224b189462f ("clk: imx: add i.MX95 BLK CTL clk driver")
Cc: stable@vger.kernel.org
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
---
v1:
https://patchwork.kernel.org/project/linux-arm-kernel/patch/20250614112255.2838154-1-xiaolei.wang@windriver.com/
v2:
https://patchwork.kernel.org/project/linux-arm-kernel/patch/20250618065318.319339-1-xiaolei.wang@windriver.com/
Use ARRAY_SIZE() instead of hardcode number here.
v3:
cc stable
drivers/clk/imx/clk-imx95-blk-ctl.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/clk/imx/clk-imx95-blk-ctl.c b/drivers/clk/imx/clk-imx95-blk-ctl.c
index 25974947ad0c..cc2ee2be1819 100644
--- a/drivers/clk/imx/clk-imx95-blk-ctl.c
+++ b/drivers/clk/imx/clk-imx95-blk-ctl.c
@@ -219,11 +219,15 @@ static const struct imx95_blk_ctl_dev_data lvds_csr_dev_data = {
.clk_reg_offset = 0,
};
+static const char * const disp_engine_parents[] = {
+ "videopll1", "dsi_pll", "ldb_pll_div7"
+};
+
static const struct imx95_blk_ctl_clk_dev_data dispmix_csr_clk_dev_data[] = {
[IMX95_CLK_DISPMIX_ENG0_SEL] = {
.name = "disp_engine0_sel",
- .parent_names = (const char *[]){"videopll1", "dsi_pll", "ldb_pll_div7", },
- .num_parents = 4,
+ .parent_names = disp_engine_parents,
+ .num_parents = ARRAY_SIZE(disp_engine_parents),
.reg = 0,
.bit_idx = 0,
.bit_width = 2,
@@ -232,8 +236,8 @@ static const struct imx95_blk_ctl_clk_dev_data dispmix_csr_clk_dev_data[] = {
},
[IMX95_CLK_DISPMIX_ENG1_SEL] = {
.name = "disp_engine1_sel",
- .parent_names = (const char *[]){"videopll1", "dsi_pll", "ldb_pll_div7", },
- .num_parents = 4,
+ .parent_names = disp_engine_parents,
+ .num_parents = ARRAY_SIZE(disp_engine_parents),
.reg = 0,
.bit_idx = 2,
.bit_width = 2,
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH v3] clk: imx: Fix an out-of-bounds access in dispmix_csr_clk_dev_data
2025-06-19 6:21 [PATCH v3] clk: imx: Fix an out-of-bounds access in dispmix_csr_clk_dev_data Xiaolei Wang
@ 2025-06-20 0:29 ` Peng Fan
2025-06-20 0:38 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Peng Fan @ 2025-06-20 0:29 UTC (permalink / raw)
To: Xiaolei Wang, abelvesa@kernel.org, Frank Li,
mturquette@baylibre.com, sboyd@kernel.org, shawnguo@kernel.org,
s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com
Cc: linux-clk@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
> Subject: [PATCH v3] clk: imx: Fix an out-of-bounds access in
> dispmix_csr_clk_dev_data
>
> When num_parents is 4, __clk_register() occurs an out-of-bounds when
> accessing parent_names member. Use ARRAY_SIZE() instead of
> hardcode number here.
>
> BUG: KASAN: global-out-of-bounds in __clk_register+0x1844/0x20d8
> Read of size 8 at addr ffff800086988e78 by task kworker/u24:3/59
> Hardware name: NXP i.MX95 19X19 board (DT)
> Workqueue: events_unbound deferred_probe_work_func
> Call trace:
> dump_backtrace+0x94/0xec
> show_stack+0x18/0x24
> dump_stack_lvl+0x8c/0xcc
> print_report+0x398/0x5fc
> kasan_report+0xd4/0x114
> __asan_report_load8_noabort+0x20/0x2c
> __clk_register+0x1844/0x20d8
> clk_hw_register+0x44/0x110
> __clk_hw_register_mux+0x284/0x3a8
> imx95_bc_probe+0x4f4/0xa70
>
> Fixes: 5224b189462f ("clk: imx: add i.MX95 BLK CTL clk driver")
> Cc: stable@vger.kernel.org
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] clk: imx: Fix an out-of-bounds access in dispmix_csr_clk_dev_data
2025-06-19 6:21 [PATCH v3] clk: imx: Fix an out-of-bounds access in dispmix_csr_clk_dev_data Xiaolei Wang
2025-06-20 0:29 ` Peng Fan
@ 2025-06-20 0:38 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2025-06-20 0:38 UTC (permalink / raw)
To: Frank.li, Xiaolei Wang, abelvesa, festevam, kernel, mturquette,
peng.fan, s.hauer, shawnguo
Cc: linux-clk, imx, linux-arm-kernel, linux-kernel
Quoting Xiaolei Wang (2025-06-18 23:21:08)
> When num_parents is 4, __clk_register() occurs an out-of-bounds
> when accessing parent_names member. Use ARRAY_SIZE() instead of
> hardcode number here.
>
> BUG: KASAN: global-out-of-bounds in __clk_register+0x1844/0x20d8
> Read of size 8 at addr ffff800086988e78 by task kworker/u24:3/59
> Hardware name: NXP i.MX95 19X19 board (DT)
> Workqueue: events_unbound deferred_probe_work_func
> Call trace:
> dump_backtrace+0x94/0xec
> show_stack+0x18/0x24
> dump_stack_lvl+0x8c/0xcc
> print_report+0x398/0x5fc
> kasan_report+0xd4/0x114
> __asan_report_load8_noabort+0x20/0x2c
> __clk_register+0x1844/0x20d8
> clk_hw_register+0x44/0x110
> __clk_hw_register_mux+0x284/0x3a8
> imx95_bc_probe+0x4f4/0xa70
>
> Fixes: 5224b189462f ("clk: imx: add i.MX95 BLK CTL clk driver")
> Cc: stable@vger.kernel.org
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
> ---
Applied to clk-fixes
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-20 0:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-19 6:21 [PATCH v3] clk: imx: Fix an out-of-bounds access in dispmix_csr_clk_dev_data Xiaolei Wang
2025-06-20 0:29 ` Peng Fan
2025-06-20 0:38 ` Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).