[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zvp9mWLKveSz5Xdo@J2N7QTR9R3>
Date: Mon, 30 Sep 2024 11:29:45 +0100
From: Mark Rutland <mark.rutland@....com>
To: Jinjie Ruan <ruanjinjie@...wei.com>
Cc: krzk@...nel.org, s.nawrocki@...sung.com, cw00.choi@...sung.com,
alim.akhtar@...sung.com, mturquette@...libre.com, sboyd@...nel.org,
sunyeal.hong@...sung.com, linux-samsung-soc@...r.kernel.org,
linux-clk@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] clk: samsung: Fix out-of-bound access of of_match_node()
On Fri, Sep 27, 2024 at 06:21:04PM +0800, Jinjie Ruan wrote:
> Currently, there is no terminator entry for exynosautov920_cmu_of_match,
> hence facing below KASAN warning,
>
> ==================================================================
> BUG: KASAN: global-out-of-bounds in of_match_node+0x120/0x13c
> Read of size 1 at addr ffffffe31cc9e628 by task swapper/0/1
> The buggy address belongs to the variable:
> exynosautov920_cmu_of_match+0xc8/0x2c80
> Add a dummy terminator entry at the end to assist
> of_match_node() in traversing up to the terminator entry
> without accessing an out-of-boundary index.
>
> Fixes: 485e13fe2fb6 ("clk: samsung: add top clock support for ExynosAuto v920 SoC")
> Signed-off-by: Jinjie Ruan <ruanjinjie@...wei.com>
FWIW, I'm hitting this while testing on v6.12-rc1, and my local fix was
essentially the same (adding a '{ /* sentintel */ }' entry), so FWIW,
with one minor nit below:
Acked-by: Mark Rutland <mark.rutland@....com>
> ---
> drivers/clk/samsung/clk-exynosautov920.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/clk/samsung/clk-exynosautov920.c b/drivers/clk/samsung/clk-exynosautov920.c
> index 7ba9748c0526..a3634003b29b 100644
> --- a/drivers/clk/samsung/clk-exynosautov920.c
> +++ b/drivers/clk/samsung/clk-exynosautov920.c
> @@ -1155,6 +1155,7 @@ static const struct of_device_id exynosautov920_cmu_of_match[] = {
> .compatible = "samsung,exynosautov920-cmu-peric0",
> .data = &peric0_cmu_info,
> },
> + { },
Nit: the sentinal entry is meant to be the last entry, so it shouldn't
have a trailing comma.
Regardless of that, it'd be nice to have this fix in -rc2, since anyone
trying to test with KASAN is going to hit this at boot time.
Mark.
> };
>
> static struct platform_driver exynosautov920_cmu_driver __refdata = {
> --
> 2.34.1
>
Powered by blists - more mailing lists