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]
Message-ID: <202504071148.6F55B7AF34@keescook>
Date: Mon, 7 Apr 2025 11:52:13 -0700
From: Kees Cook <kees@...nel.org>
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: gadget: uvc: Avoid
 -Wflex-array-member-not-at-end warnings

On Mon, Mar 17, 2025 at 11:22:51AM +1030, 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 uvc_input_header_descriptor` is a flexible structure --a
> structure that contains a flexible-array member.
> 
> With this, fix three of the following warnings:
> 
> drivers/usb/gadget/function/uvc_configfs.h:77:57: 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/gadget/function/uvc_configfs.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/function/uvc_configfs.h b/drivers/usb/gadget/function/uvc_configfs.h
> index 2f78cd4f396f..9391614135e9 100644
> --- a/drivers/usb/gadget/function/uvc_configfs.h
> +++ b/drivers/usb/gadget/function/uvc_configfs.h
> @@ -74,10 +74,12 @@ static inline struct uvcg_format *to_uvcg_format(struct config_item *item)
>  
>  struct uvcg_streaming_header {
>  	struct config_item				item;
> -	struct uvc_input_header_descriptor		desc;
>  	unsigned					linked;
>  	struct list_head				formats;
>  	unsigned					num_fmt;
> +
> +	/* Must be last --ends in a flexible-array member. */
> +	struct uvc_input_header_descriptor		desc;
>  };
>  
>  static inline struct uvcg_streaming_header *to_uvcg_streaming_header(struct config_item *item)

This looks correct to me, and may be fixing some bugs -- I can see the
allocation routine for this is already expecting the bmaControls (in
desc) to be trailing:

                /* bmaControls */
                *size += h->num_fmt * UVCG_STREAMING_CONTROL_SIZE;

Reviewed-by: Kees Cook <kees@...nel.org>

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ