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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241101101512.eee2nkaqgffsoxe3@quack3>
Date: Fri, 1 Nov 2024 11:15:12 +0100
From: Jan Kara <jack@...e.cz>
To: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
Cc: Jan Kara <jack@...e.cz>, "Gustavo A. R. Silva" <gustavoars@...nel.org>,
	Theodore Ts'o <tytso@....edu>, Jan Kara <jack@...e.com>,
	linux-ext4@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-hardening@...r.kernel.org
Subject: Re: [PATCH][next] jbd2: Avoid dozens of
 -Wflex-array-member-not-at-end warnings

On Thu 31-10-24 17:31:34, Gustavo A. R. Silva wrote:
> On 31/10/24 15:32, Jan Kara wrote:
> > 
> > > `sizeof(ctx) == 4` when `char ctx[JBD_MAX_CHECKSUM_SIZE];`
> > > 
> > > To maintain the same size, we tell `DEFINE_RAW_FLEX()` to allocate `1`
> > > element for the flex array, as in 32-bit `sizeof(void *) == 4`.
> > 
> > So I agree we end up allocating enough space on stack but it is pretty
> > subtle and if JBD_MAX_CHECKSUM_SIZE definition changes, we have a problem.
> > I think we need something like (JBD_MAX_CHECKSUM_SIZE + sizeof(*desc->__ctx)
> > - 1) / sizeof(*desc->__ctx))?
> 
> I see. Well, in that case it'd be something more like:
> 
> -       struct {
> -               struct shash_desc shash;
> -               char ctx[JBD_MAX_CHECKSUM_SIZE];
> -       } desc;
> +       DEFINE_RAW_FLEX(struct shash_desc, desc, __ctx,
> +                       (JBD_MAX_CHECKSUM_SIZE +
> +                        sizeof(*((struct shash_desc *)0)->__ctx)) /
> +                        sizeof(*((struct shash_desc *)0)->__ctx));
> 
> Notice that `desc` is created inside `DEFINE_RAW_FLEX()`
  Right. Thanks for fixing this. The cleanest option then probably is:

	DEFINE_RAW_FLEX(struct shash_desc, desc, __ctx,
		DIV_ROUND_UP(JBD_MAX_CHECKSUM_SIZE,
			     sizeof(*((struct shash_desc *)0)->__ctx)))

									Honza
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ