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: Sun, 10 Mar 2024 15:41:58 -0400
From: Kent Overstreet <kent.overstreet@...ux.dev>
To: Erick Archer <erick.archer@....com>
Cc: Brian Foster <bfoster@...hat.com>, 
	"Gustavo A. R. Silva" <gustavoars@...nel.org>, Kees Cook <keescook@...omium.org>, 
	linux-bcachefs@...r.kernel.org, linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH v2] bcachefs: Prefer struct_size over open coded
 arithmetic

On Sun, Mar 10, 2024 at 12:02:26PM +0100, 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 "op" variable is a pointer to "struct promote_op" and this
> structure ends in a flexible array:
> 
> struct promote_op {
> 	[...]
> 	struct bio_vec bi_inline_vecs[];
> };
> 
> and the "t" variable is a pointer to "struct journal_seq_blacklist_table"
> and this structure also ends in a flexible array:
> 
> struct journal_seq_blacklist_table {
> 	[...]
> 	struct journal_seq_blacklist_table_entry {
> 		u64		start;
> 		u64		end;
> 		bool		dirty;
> 	}			entries[];
> };
> 
> 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
> kzalloc() functions.
> 
> 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>

applied

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ