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: <1e82761e-8554-4168-8feb-561abbe49f7e@rowland.harvard.edu>
Date: Wed, 26 Mar 2025 22:09:09 -0400
From: Alan Stern <stern@...land.harvard.edu>
To: "Gustavo A. R. Silva" <gustavoars@...nel.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-hardening@...r.kernel.org
Subject: Re: [PATCH][next] usb: ehci-fsl: Avoid
 -Wflex-array-member-not-at-end warning

On Wed, Mar 26, 2025 at 04:17:41PM -0600, Gustavo A. R. Silva wrote:
> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
> getting ready to enable it, globally.
> 
> Move the conflicting declaration to the end of the structure. Notice
> that `struct ehci_hcd` is a flexible structure --a structure that
> contains a flexible-array member.
> 
> Fix the following warning:
> 
> drivers/usb/host/ehci-fsl.c:414:25: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> 
> Signed-off-by: Gustavo A. R. Silva <gustavoars@...nel.org>
> ---
>  drivers/usb/host/ehci-fsl.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> index 26f13278d4d6..c720d55f4982 100644
> --- a/drivers/usb/host/ehci-fsl.c
> +++ b/drivers/usb/host/ehci-fsl.c
> @@ -411,12 +411,13 @@ static int ehci_fsl_setup(struct usb_hcd *hcd)
>  }
>  
>  struct ehci_fsl {
> -	struct ehci_hcd	ehci;
> -
>  #ifdef CONFIG_PM
>  	/* Saved USB PHY settings, need to restore after deep sleep. */
>  	u32 usb_ctrl;
>  #endif
> +
> +	/* Must be last --ends in a flexible-array member. */
> +	struct ehci_hcd	ehci;
>  };
>  
>  #ifdef CONFIG_PM

While the sentiment is laudable, this mechanical change simply will not 
work.  The driver was written incorrectly to begin with, and the change 
will probably break it.

I'll try to find time soon to create a proper fix.  In short, the 
usb_ctrl field should have been stored in the .priv flex member of the 
ehci_hcd structure all along, and the .extra_priv_size member of 
ehci_fsl_overrides should have been set to the size of this u32 field, 
not the size of the entire ehci_fsl structure.

Alan Stern

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ