lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8182279.JRmrKFJ9eK@diego>
Date: Fri, 07 Jun 2024 10:13:04 +0200
From: Heiko Stübner <heiko@...ech.de>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
 Sam Protsenko <semen.protsenko@...aro.org>,
 Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
 linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org,
 linux-arm-kernel@...ts.infradead.org, linux-rockchip@...ts.infradead.org,
 linux-samsung-soc@...r.kernel.org,
 Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Michael Turquette <mturquette@...libre.com>,
 Stephen Boyd <sboyd@...nel.org>, Krzysztof Kozlowski <krzk@...nel.org>,
 Sylwester Nawrocki <s.nawrocki@...sung.com>,
 Chanwoo Choi <cw00.choi@...sung.com>, Alim Akhtar <alim.akhtar@...sung.com>,
 Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@...hiba.co.jp>
Subject: Re: [PATCH v1 2/4] clk: rockchip: Switch to use kmemdup_array()

Hi Andy,

Am Donnerstag, 6. Juni 2024, 18:09:32 CEST schrieb Andy Shevchenko:
> Let the kememdup_array() take care about multiplication and possible
> overflows.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---
>  drivers/clk/rockchip/clk-cpu.c | 5 ++---
>  drivers/clk/rockchip/clk-pll.c | 8 ++++----
>  2 files changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/clk/rockchip/clk-cpu.c b/drivers/clk/rockchip/clk-cpu.c
> index 6ea7fba9f9e5..398a226ad34e 100644
> --- a/drivers/clk/rockchip/clk-cpu.c
> +++ b/drivers/clk/rockchip/clk-cpu.c
> @@ -369,9 +369,8 @@ struct clk *rockchip_clk_register_cpuclk(const char *name,
>  
>  	if (nrates > 0) {
>  		cpuclk->rate_count = nrates;
> -		cpuclk->rate_table = kmemdup(rates,
> -					     sizeof(*rates) * nrates,
> -					     GFP_KERNEL);
> +		cpuclk->rate_table = kmemdup_array(rates, nrates, sizeof(*rates),
> +						   GFP_KERNEL);

are you sure the param order is correct?

According to [0], it's (src, element_size, count, gfp), while above
(and below) element_size and count seems switched in the
kmemdup_array calls.


Heiko

[0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/util.c#n149

>  		if (!cpuclk->rate_table) {
>  			ret = -ENOMEM;
>  			goto unregister_notifier;
> diff --git a/drivers/clk/rockchip/clk-pll.c b/drivers/clk/rockchip/clk-pll.c
> index 2d42eb628926..606ce5458f54 100644
> --- a/drivers/clk/rockchip/clk-pll.c
> +++ b/drivers/clk/rockchip/clk-pll.c
> @@ -1136,10 +1136,10 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,
>  			len++;
>  
>  		pll->rate_count = len;
> -		pll->rate_table = kmemdup(rate_table,
> -					pll->rate_count *
> -					sizeof(struct rockchip_pll_rate_table),
> -					GFP_KERNEL);
> +		pll->rate_table = kmemdup_array(rate_table,
> +						pll->rate_count,
> +						sizeof(*pll->rate_table),
> +						GFP_KERNEL);
>  		WARN(!pll->rate_table,
>  			"%s: could not allocate rate table for %s\n",
>  			__func__, name);
> 





Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ