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: <2025020513-arena-tackling-1741@gregkh>
Date: Wed, 5 Feb 2025 09:16:45 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
Cc: Jiri Slaby <jirislaby@...nel.org>,
	"Gustavo A. R. Silva" <gustavoars@...nel.org>,
	linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org,
	linux-hardening@...r.kernel.org
Subject: Re: [PATCH][next] tty: tty_buffer: Avoid hundreds of
 -Wflex-array-member-not-at-end warnings

On Wed, Feb 05, 2025 at 06:33:13PM +1030, Gustavo A. R. Silva wrote:
> 
> 
> On 05/02/25 17:29, Jiri Slaby wrote:
> > On 05. 02. 25, 7:49, Gustavo A. R. Silva wrote:
> > > If the above changes are better for you then I'll send a new patch. :)
> > 
> > No, you are supposed to switch tty_buffer to tty_buffer_hdr too.
> 
> Do you mean something like the following:
> 
>  struct tty_buffer {
> -       union {
> -               struct tty_buffer *next;
> -               struct llist_node free;
> -       };
> -       unsigned int used;
> -       unsigned int size;
> -       unsigned int commit;
> -       unsigned int lookahead;         /* Lazy update on recv, can become less than "read" */
> -       unsigned int read;
> -       bool flags;
> +       struct tty_buffer_hdr hdr;
>         /* Data points here */
>         u8 data[] __aligned(sizeof(unsigned long));
>  };
> 
> +struct tty_buffer_hdr {
> +        union {
> +                struct tty_buffer *next;
> +                struct llist_node free;
> +        };
> +        unsigned int used;
> +        unsigned int size;
> +        unsigned int commit;
> +        unsigned int lookahead; /* Lazy update on recv, can become less than "read" */
> +        unsigned int read;
> +        bool flags;
> +};
> +

Yes!

> The problem with this is that then we have to modify a lot of
> lines from, let's say, instance->used, instance->size, etc...
> to instance->hdr.used, instance->hdr.size, and so on...

Great, let's do that and get it right please.

> This code churn is avoided if we use the struct_group() helper.

It's not "churn" if it is "fix the code to be correct" :)

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ