public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2][next] Bluetooth: Avoid a couple dozen -Wflex-array-member-not-at-end warnings
@ 2025-09-09 12:13 Gustavo A. R. Silva
  2025-09-09 12:49 ` [v2,next] " bluez.test.bot
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Gustavo A. R. Silva @ 2025-09-09 12:13 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman
  Cc: linux-bluetooth, netdev, linux-kernel, Gustavo A. R. Silva,
	linux-hardening

-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_
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* RE: [v2,next] Bluetooth: Avoid a couple dozen -Wflex-array-member-not-at-end warnings
  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-09 12:49 ` bluez.test.bot
  2025-09-10 10:25 ` [PATCH v2][next] " Simon Horman
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: bluez.test.bot @ 2025-09-09 12:49 UTC (permalink / raw)
  To: linux-bluetooth, gustavoars

[-- Attachment #1: Type: text/plain, Size: 2297 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1000473

---Test result---

Test Summary:
CheckPatch                    PENDING   0.50 seconds
GitLint                       PENDING   0.25 seconds
SubjectPrefix                 PASS      0.08 seconds
BuildKernel                   PASS      24.72 seconds
CheckAllWarning               PASS      27.53 seconds
CheckSparse                   PASS      30.82 seconds
BuildKernel32                 PASS      24.53 seconds
TestRunnerSetup               PASS      486.66 seconds
TestRunner_l2cap-tester       PASS      25.33 seconds
TestRunner_iso-tester         PASS      39.31 seconds
TestRunner_bnep-tester        PASS      5.99 seconds
TestRunner_mgmt-tester        FAIL      127.39 seconds
TestRunner_rfcomm-tester      PASS      9.29 seconds
TestRunner_sco-tester         PASS      14.82 seconds
TestRunner_ioctl-tester       PASS      10.08 seconds
TestRunner_mesh-tester        FAIL      11.54 seconds
TestRunner_smp-tester         PASS      8.63 seconds
TestRunner_userchan-tester    PASS      6.27 seconds
IncrementalBuild              PENDING   0.56 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 490, Passed: 485 (99.0%), Failed: 1, Not Run: 4

Failed Test Cases
Read Exp Feature - Success                           Failed       0.107 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0

Failed Test Cases
Mesh - Send cancel - 1                               Timed out    1.991 seconds
Mesh - Send cancel - 2                               Timed out    1.998 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2][next] Bluetooth: Avoid a couple dozen -Wflex-array-member-not-at-end warnings
  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-09 12:49 ` [v2,next] " bluez.test.bot
@ 2025-09-10 10:25 ` Simon Horman
  2025-09-10 11:11 ` Paul Menzel
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Simon Horman @ 2025-09-10 10:25 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-bluetooth, netdev, linux-kernel, linux-hardening

On Tue, Sep 09, 2025 at 02:13:35PM +0200, 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/

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2][next] Bluetooth: Avoid a couple dozen -Wflex-array-member-not-at-end warnings
  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-09 12:49 ` [v2,next] " bluez.test.bot
  2025-09-10 10:25 ` [PATCH v2][next] " Simon Horman
@ 2025-09-10 11:11 ` Paul Menzel
  2025-09-25 12:37 ` Gustavo A. R. Silva
  2025-09-25 13:40 ` patchwork-bot+bluetooth
  4 siblings, 0 replies; 7+ messages in thread
From: Paul Menzel @ 2025-09-10 11:11 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, linux-bluetooth, netdev, linux-kernel,
	linux-hardening

Dear Gustavo,


Thank you for your patch.

Am 09.09.25 um 14:13 schrieb Gustavo A. R. Silva:
> -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]

You could add an explanation, why the macro `__struct_group()` defined 
in `include/uapi/linux/stddef.h` fixes this, and why it is preferred 
over `TRAILING_OVERLAP()`. Also, the two underscores would suggest to 
me, it’s some kind of internal implementation.

> 
> 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_
>   


Kind regards,

Paul

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2][next] Bluetooth: Avoid a couple dozen -Wflex-array-member-not-at-end warnings
  2025-09-09 12:13 [PATCH v2][next] Bluetooth: Avoid a couple dozen -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
                   ` (2 preceding siblings ...)
  2025-09-10 11:11 ` Paul Menzel
@ 2025-09-25 12:37 ` Gustavo A. R. Silva
  2025-09-25 13:40 ` patchwork-bot+bluetooth
  4 siblings, 0 replies; 7+ messages in thread
From: Gustavo A. R. Silva @ 2025-09-25 12:37 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Marcel Holtmann, Johan Hedberg,
	Luiz Augusto von Dentz, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman
  Cc: linux-bluetooth, netdev, linux-kernel, linux-hardening

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_
>   


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2][next] Bluetooth: Avoid a couple dozen -Wflex-array-member-not-at-end warnings
  2025-09-09 12:13 [PATCH v2][next] Bluetooth: Avoid a couple dozen -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
                   ` (3 preceding siblings ...)
  2025-09-25 12:37 ` Gustavo A. R. Silva
@ 2025-09-25 13:40 ` patchwork-bot+bluetooth
  2025-09-25 13:46   ` Gustavo A. R. Silva
  4 siblings, 1 reply; 7+ messages in thread
From: patchwork-bot+bluetooth @ 2025-09-25 13:40 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: marcel, johan.hedberg, luiz.dentz, davem, edumazet, kuba, pabeni,
	horms, linux-bluetooth, netdev, linux-kernel, linux-hardening

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue, 9 Sep 2025 14:13:35 +0200 you 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]
> 
> [...]

Here is the summary with links:
  - [v2,next] Bluetooth: Avoid a couple dozen -Wflex-array-member-not-at-end warnings
    https://git.kernel.org/bluetooth/bluetooth-next/c/33c9dc51e8b4

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2][next] Bluetooth: Avoid a couple dozen -Wflex-array-member-not-at-end warnings
  2025-09-25 13:40 ` patchwork-bot+bluetooth
@ 2025-09-25 13:46   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 7+ messages in thread
From: Gustavo A. R. Silva @ 2025-09-25 13:46 UTC (permalink / raw)
  To: luiz.dentz, Gustavo A. R. Silva
  Cc: marcel, johan.hedberg, davem, edumazet, kuba, pabeni, horms,
	linux-bluetooth, netdev, linux-kernel, linux-hardening



On 9/25/25 15:40, patchwork-bot+bluetooth@kernel.org wrote:
> Hello:
> 
> This patch was applied to bluetooth/bluetooth-next.git (master)
> by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

Thank you, Luiz!

-Gustavo

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-09-25 13:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-09 12:49 ` [v2,next] " bluez.test.bot
2025-09-10 10:25 ` [PATCH v2][next] " Simon Horman
2025-09-10 11:11 ` Paul Menzel
2025-09-25 12:37 ` Gustavo A. R. Silva
2025-09-25 13:40 ` patchwork-bot+bluetooth
2025-09-25 13:46   ` Gustavo A. R. Silva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox