[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <81dc43d9-1a65-4cf3-967c-9ee3458de26a@gmail.com>
Date: Sat, 24 Feb 2024 23:39:22 +0200
From: Sergey Ryazanov <ryazanov.s.a@...il.com>
To: Erick Archer <erick.archer@....com>,
Chandrashekar Devegowda <chandrashekar.devegowda@...el.com>,
Chiranjeevi Rapolu <chiranjeevi.rapolu@...ux.intel.com>,
Liu Haijun <haijun.liu@...iatek.com>,
M Chetan Kumar <m.chetan.kumar@...ux.intel.com>,
Ricardo Martinez <ricardo.martinez@...ux.intel.com>,
Loic Poulain <loic.poulain@...aro.org>,
Johannes Berg <johannes@...solutions.net>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
Kees Cook <keescook@...omium.org>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org
Subject: Re: [PATCH] net: wwan: t7xx: Prefer struct_size over open coded
arithmetic
On 24.02.2024 20:19, Erick Archer wrote:
> This is an effort to get rid of all multiplications from allocation
> functions in order to prevent integer overflows [1][2].
>
> As the "port_prox" variable is a pointer to "struct port_proxy" and
> this structure ends in a flexible array:
>
> struct port_proxy {
> [...]
> struct t7xx_port ports[];
> };
>
> the preferred way in the kernel is to use the struct_size() helper to
> do the arithmetic instead of the argument "size + size * count" in the
> devm_kzalloc() function.
>
> This way, the code is more readable and safer.
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1]
> Link: https://github.com/KSPP/linux/issues/160 [2]
>
> Signed-off-by: Erick Archer <erick.archer@....com>
Reviewed-by: Sergey Ryazanov <ryazanov.s.a@...il.com>
Powered by blists - more mailing lists