From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
Marcel Holtmann <marcel@holtmann.org>,
Johan Hedberg <johan.hedberg@gmail.com>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>
Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH v2][next] Bluetooth: Avoid a couple dozen -Wflex-array-member-not-at-end warnings
Date: Thu, 25 Sep 2025 14:37:39 +0200 [thread overview]
Message-ID: <8497d3e4-fa7f-436c-9e94-b669c7be73f1@embeddedor.com> (raw)
In-Reply-To: <aMAZ7wIeT1sDZ4_V@kspp>
Hi all,
Friendly ping: who can take this, please? :)
Thanks!
-Gustavo
On 9/9/25 14:13, 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.
>
> Use the __struct_group() helper to fix 31 instances of the following
> type of warnings:
>
> 30 net/bluetooth/mgmt_config.c:16:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> 1 net/bluetooth/mgmt_config.c:22:33: 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>
> ---
> Changes in v2:
> - Use __struct_group() instead of TRAILING_OVERLAP().
>
> v1:
> - Link: https://lore.kernel.org/linux-hardening/aLSCu8U62Hve7Dau@kspp/
>
> include/net/bluetooth/mgmt.h | 9 +++++++--
> net/bluetooth/mgmt_config.c | 4 ++--
> 2 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
> index 3575cd16049a..74edea06985b 100644
> --- a/include/net/bluetooth/mgmt.h
> +++ b/include/net/bluetooth/mgmt.h
> @@ -53,10 +53,15 @@ struct mgmt_hdr {
> } __packed;
>
> struct mgmt_tlv {
> - __le16 type;
> - __u8 length;
> + /* New members MUST be added within the __struct_group() macro below. */
> + __struct_group(mgmt_tlv_hdr, __hdr, __packed,
> + __le16 type;
> + __u8 length;
> + );
> __u8 value[];
> } __packed;
> +static_assert(offsetof(struct mgmt_tlv, value) == sizeof(struct mgmt_tlv_hdr),
> + "struct member likely outside of __struct_group()");
>
> struct mgmt_addr_info {
> bdaddr_t bdaddr;
> diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c
> index 6ef701c27da4..c4063d200c0a 100644
> --- a/net/bluetooth/mgmt_config.c
> +++ b/net/bluetooth/mgmt_config.c
> @@ -13,13 +13,13 @@
>
> #define HDEV_PARAM_U16(_param_name_) \
> struct {\
> - struct mgmt_tlv entry; \
> + struct mgmt_tlv_hdr entry; \
> __le16 value; \
> } __packed _param_name_
>
> #define HDEV_PARAM_U8(_param_name_) \
> struct {\
> - struct mgmt_tlv entry; \
> + struct mgmt_tlv_hdr entry; \
> __u8 value; \
> } __packed _param_name_
>
next prev parent reply other threads:[~2025-09-25 12:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-09 12:13 [PATCH v2][next] Bluetooth: Avoid a couple dozen -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
2025-09-10 10:25 ` Simon Horman
2025-09-10 11:11 ` Paul Menzel
2025-09-25 12:37 ` Gustavo A. R. Silva [this message]
2025-09-25 13:40 ` patchwork-bot+bluetooth
2025-09-25 13:46 ` Gustavo A. R. Silva
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=8497d3e4-fa7f-436c-9e94-b669c7be73f1@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gustavoars@kernel.org \
--cc=horms@kernel.org \
--cc=johan.hedberg@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).