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] [day] [month] [year] [list]
Date: Mon, 26 Feb 2024 11:44:56 +0100
From: Miquel Raynal <miquel.raynal@...tlin.com>
To: Erick Archer <erick.archer@....com>,
	Miquel Raynal <miquel.raynal@...tlin.com>,
	Richard Weinberger <richard@....at>,
	Vignesh Raghavendra <vigneshr@...com>,
	Matthias Brugger <matthias.bgg@...il.com>,
	AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
	Martin Blumenstingl <martin.blumenstingl@...glemail.com>,
	Heiko Stuebner <heiko@...ech.de>,
	Philippe Mathieu-Daudé <philmd@...aro.org>,
	Rob Herring <robh@...nel.org>,
	Li Zetao <lizetao1@...wei.com>,
	Uwe Kleine-König <u.kleine-koenig@...gutronix.de>,
	"Gustavo A. R. Silva" <gustavoars@...nel.org>,
	Kees Cook <keescook@...omium.org>
Cc: linux-mtd@...ts.infradead.org,
	linux-kernel@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org,
	linux-mediatek@...ts.infradead.org,
	linux-hardening@...r.kernel.org
Subject: Re: [PATCH v2] mtd: rawnand: Prefer struct_size over open coded arithmetic

On Sun, 2024-02-11 at 09:16:33 UTC, Erick Archer wrote:
> This is an effort to get rid of all multiplications from allocation
> functions in order to prevent integer overflows [1].
> 
> As the "chip" variable is a pointer to "struct mtk_nfc_nand_chip" and
> this structure ends in a flexible array:
> 
> struct mtk_nfc_nand_chip {
> 	[...]
> 	u8 sels[] __counted_by(nsels);
> };
> 
> the preferred way in the kernel is to use the struct_size() helper to
> do the arithmetic instead of the argument "size + count * size" 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]
> Reviewed-by: Gustavo A. R. Silva <gustavoars@...nel.org>
> Signed-off-by: Erick Archer <erick.archer@....com>
> Acked-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
> Reviewed-by: Matthias Brugger <matthias.bgg@...il.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ