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: <60f43759-ea04-41af-9667-006018e5c750@embeddedor.com>
Date: Mon, 4 Mar 2024 10:16:42 -0600
From: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
To: David Lechner <dlechner@...libre.com>, Mark Brown <broonie@...nel.org>
Cc: Michael Hennerich <michael.hennerich@...log.com>,
 Nuno Sá <nuno.sa@...log.com>,
 Kees Cook <keescook@...omium.org>,
 "Gustavo A. R. Silva" <gustavoars@...nel.org>, linux-spi@...r.kernel.org,
 linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org,
 Christophe JAILLET <christophe.jaillet@...adoo.fr>
Subject: Re: [PATCH v2 3/3] spi: axi-spi-engine: use struct_size() macro



On 04/03/24 10:04, David Lechner wrote:
> This makes use of the struct_size() macro to calculate the size of the
> struct axi_spi_engine when allocating it.
> 
> Suggested-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
> Reviewed-by: Kees Cook <keescook@...omium.org>
> Signed-off-by: David Lechner <dlechner@...libre.com>

Reviewed-by: Gustavo A. R. Silva <gustavoars@...nel.org>

Thanks
--
Gustavo

> ---
>   drivers/spi/spi-axi-spi-engine.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c
> index a8f626165f44..7cc219d78551 100644
> --- a/drivers/spi/spi-axi-spi-engine.c
> +++ b/drivers/spi/spi-axi-spi-engine.c
> @@ -12,6 +12,7 @@
>   #include <linux/io.h>
>   #include <linux/of.h>
>   #include <linux/module.h>
> +#include <linux/overflow.h>
>   #include <linux/platform_device.h>
>   #include <linux/spi/spi.h>
>   
> @@ -502,15 +503,13 @@ static irqreturn_t spi_engine_irq(int irq, void *devid)
>   static int spi_engine_optimize_message(struct spi_message *msg)
>   {
>   	struct spi_engine_program p_dry, *p;
> -	size_t size;
>   
>   	spi_engine_precompile_message(msg);
>   
>   	p_dry.length = 0;
>   	spi_engine_compile_message(msg, true, &p_dry);
>   
> -	size = sizeof(*p->instructions) * (p_dry.length + 1);
> -	p = kzalloc(sizeof(*p) + size, GFP_KERNEL);
> +	p = kzalloc(struct_size(p, instructions, p_dry.length + 1), GFP_KERNEL);
>   	if (!p)
>   		return -ENOMEM;
>   
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ