From: Kees Cook <kees@kernel.org>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] usb: gadget: uvc: Avoid -Wflex-array-member-not-at-end warnings
Date: Mon, 7 Apr 2025 11:52:13 -0700 [thread overview]
Message-ID: <202504071148.6F55B7AF34@keescook> (raw)
In-Reply-To: <Z9dyY7_ydJiGqh_d@kspp>
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@kernel.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@kernel.org>
--
Kees Cook
prev parent reply other threads:[~2025-04-07 18:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-17 0:52 [PATCH][next] usb: gadget: uvc: Avoid -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
2025-04-07 18:52 ` Kees Cook [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202504071148.6F55B7AF34@keescook \
--to=kees@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=gustavoars@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox