Re: [PATCH] clk: samsung: Fix out-of-bound access of of_match_node()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

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

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




[Index of Archives]     [Linux SoC Development]     [Linux Rockchip Development]     [Linux for Synopsys ARC Processors]    
  • [Linux on Unisoc (RDA Micro) SoCs]     [Linux Actions SoC]     [Linux USB Development]     [Video for Linux]     [Linux Audio Users]     [Linux SCSI]     [Yosemite News]

  •   Powered by Linux