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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <f0c79ce0-aa59-465b-ae10-f48e74038f69@embeddedor.com>
Date: Sun, 31 Aug 2025 20:02:32 +0200
From: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
To: "Gustavo A. R. Silva" <gustavoars@...nel.org>,
 Marcel Holtmann <marcel@...tmann.org>,
 Johan Hedberg <johan.hedberg@...il.com>,
 Luiz Augusto von Dentz <luiz.dentz@...il.com>
Cc: linux-bluetooth@...r.kernel.org, linux-kernel@...r.kernel.org,
 linux-hardening@...r.kernel.org
Subject: Re: [PATCH][next] Bluetooth: Avoid a couple dozen
 -Wflex-array-member-not-at-end warnings

Hi all,

Please, drop this. I just remembered about this bugfix for GCC:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120354

which will actually catch the same -Wfamnae issues inside
struct mgmt_rp_read_def_system_config:

struct mgmt_rp_read_def_system_config {
	union {
		struct mgmt_tlv    entry;                /*     0     3 */
		struct {
			unsigned char __offset_to_value[3]; /*     0     3 */

			/* XXX 1 byte hole, try to pack */

			__le16     value;                /*     4     2 */
		};                                       /*     0     6 */
	} def_page_scan_type;                            /*     0     6 */
	union {
		struct mgmt_tlv    entry;                /*     6     3 */
		struct {
			unsigned char __offset_to_value[3]; /*     6     3 */

			/* XXX 1 byte hole, try to pack */

			__le16     value;                /*    10     2 */
		};                                       /*     6     6 */
	} def_page_scan_int;                             /*     6     6 */
	union {
		struct mgmt_tlv    entry;                /*    12     3 */
		struct {
			unsigned char __offset_to_value[3]; /*    12     3 */

			/* XXX 1 byte hole, try to pack */

			__le16     value;                /*    16     2 */
		};                                       /*    12     6 */
	} def_page_scan_window;                          /*    12     6 */
...
}...

So, I need to figure out another solution for this.

Thanks
-Gustavo

On 8/31/25 19: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 new TRAILING_OVERLAP() 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]
> 
> This helper creates a union between a flexible-array member (FAM)
> and a set of members that would otherwise follow it. This overlays
> the trailing members onto the FAM while preserving the original
> memory layout.
> 
> Also, as the structs turn into unions, both members `entry` and
> `value` cannot be statically initialized at once. Create another
> macro to initialize everything after the declaration of `rp`.
> 
> Signed-off-by: Gustavo A. R. Silva <gustavoars@...nel.org>
> ---
>   net/bluetooth/mgmt_config.c | 97 +++++++++++++++++++------------------
>   1 file changed, 51 insertions(+), 46 deletions(-)
> 
> diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c
> index 6ef701c27da4..829c9cfcea7d 100644
> --- a/net/bluetooth/mgmt_config.c
> +++ b/net/bluetooth/mgmt_config.c
> @@ -12,35 +12,71 @@
>   #include "mgmt_config.h"
>   
>   #define HDEV_PARAM_U16(_param_name_) \
> -	struct {\
> -		struct mgmt_tlv entry; \
> +	TRAILING_OVERLAP(struct mgmt_tlv, entry, value, \
>   		__le16 value; \
> -	} __packed _param_name_
> +	) __packed _param_name_
>   
>   #define HDEV_PARAM_U8(_param_name_) \
> -	struct {\
> -		struct mgmt_tlv entry; \
> +	TRAILING_OVERLAP(struct mgmt_tlv, entry, value, \
>   		__u8 value; \
> -	} __packed _param_name_
> +	) __packed _param_name_
>   
>   #define TLV_SET_U16(_param_code_, _param_name_) \
>   	{ \
> -		{ cpu_to_le16(_param_code_), sizeof(__u16) }, \
> -		cpu_to_le16(hdev->_param_name_) \
> +		rp._param_name_.entry.type = cpu_to_le16(_param_code_); \
> +		rp._param_name_.entry.length = sizeof(__u16); \
> +		rp._param_name_.value = cpu_to_le16(hdev->_param_name_); \
>   	}
>   
>   #define TLV_SET_U8(_param_code_, _param_name_) \
>   	{ \
> -		{ cpu_to_le16(_param_code_), sizeof(__u8) }, \
> -		hdev->_param_name_ \
> +		rp._param_name_.entry.type = cpu_to_le16(_param_code_); \
> +		rp._param_name_.entry.length = sizeof(__u8); \
> +		rp._param_name_.value = hdev->_param_name_; \
>   	}
>   
>   #define TLV_SET_U16_JIFFIES_TO_MSECS(_param_code_, _param_name_) \
>   	{ \
> -		{ cpu_to_le16(_param_code_), sizeof(__u16) }, \
> -		cpu_to_le16(jiffies_to_msecs(hdev->_param_name_)) \
> +		rp._param_name_.entry.type = cpu_to_le16(_param_code_); \
> +		rp._param_name_.entry.length = sizeof(__u16); \
> +		rp._param_name_.value = cpu_to_le16(jiffies_to_msecs(hdev->_param_name_)); \
>   	}
>   
> +#define TLV_SET_ALL() \
> +{ \
> +	TLV_SET_U16(0x0000, def_page_scan_type); \
> +	TLV_SET_U16(0x0001, def_page_scan_int); \
> +	TLV_SET_U16(0x0002, def_page_scan_window); \
> +	TLV_SET_U16(0x0003, def_inq_scan_type);  \
> +	TLV_SET_U16(0x0004, def_inq_scan_int); \
> +	TLV_SET_U16(0x0005, def_inq_scan_window); \
> +	TLV_SET_U16(0x0006, def_br_lsto); \
> +	TLV_SET_U16(0x0007, def_page_timeout); \
> +	TLV_SET_U16(0x0008, sniff_min_interval); \
> +	TLV_SET_U16(0x0009, sniff_max_interval); \
> +	TLV_SET_U16(0x000a, le_adv_min_interval); \
> +	TLV_SET_U16(0x000b, le_adv_max_interval); \
> +	TLV_SET_U16(0x000c, def_multi_adv_rotation_duration); \
> +	TLV_SET_U16(0x000d, le_scan_interval); \
> +	TLV_SET_U16(0x000e, le_scan_window); \
> +	TLV_SET_U16(0x000f, le_scan_int_suspend); \
> +	TLV_SET_U16(0x0010, le_scan_window_suspend); \
> +	TLV_SET_U16(0x0011, le_scan_int_discovery); \
> +	TLV_SET_U16(0x0012, le_scan_window_discovery); \
> +	TLV_SET_U16(0x0013, le_scan_int_adv_monitor); \
> +	TLV_SET_U16(0x0014, le_scan_window_adv_monitor); \
> +	TLV_SET_U16(0x0015, le_scan_int_connect); \
> +	TLV_SET_U16(0x0016, le_scan_window_connect); \
> +	TLV_SET_U16(0x0017, le_conn_min_interval); \
> +	TLV_SET_U16(0x0018, le_conn_max_interval); \
> +	TLV_SET_U16(0x0019, le_conn_latency); \
> +	TLV_SET_U16(0x001a, le_supv_timeout); \
> +	TLV_SET_U16_JIFFIES_TO_MSECS(0x001b, def_le_autoconnect_timeout); \
> +	TLV_SET_U16(0x001d, advmon_allowlist_duration); \
> +	TLV_SET_U16(0x001e, advmon_no_filter_duration); \
> +	TLV_SET_U8(0x001f, enable_advmon_interleave_scan); \
> +}
> +
>   int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
>   			   u16 data_len)
>   {
> @@ -78,40 +114,9 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
>   		HDEV_PARAM_U16(advmon_allowlist_duration);
>   		HDEV_PARAM_U16(advmon_no_filter_duration);
>   		HDEV_PARAM_U8(enable_advmon_interleave_scan);
> -	} __packed rp = {
> -		TLV_SET_U16(0x0000, def_page_scan_type),
> -		TLV_SET_U16(0x0001, def_page_scan_int),
> -		TLV_SET_U16(0x0002, def_page_scan_window),
> -		TLV_SET_U16(0x0003, def_inq_scan_type),
> -		TLV_SET_U16(0x0004, def_inq_scan_int),
> -		TLV_SET_U16(0x0005, def_inq_scan_window),
> -		TLV_SET_U16(0x0006, def_br_lsto),
> -		TLV_SET_U16(0x0007, def_page_timeout),
> -		TLV_SET_U16(0x0008, sniff_min_interval),
> -		TLV_SET_U16(0x0009, sniff_max_interval),
> -		TLV_SET_U16(0x000a, le_adv_min_interval),
> -		TLV_SET_U16(0x000b, le_adv_max_interval),
> -		TLV_SET_U16(0x000c, def_multi_adv_rotation_duration),
> -		TLV_SET_U16(0x000d, le_scan_interval),
> -		TLV_SET_U16(0x000e, le_scan_window),
> -		TLV_SET_U16(0x000f, le_scan_int_suspend),
> -		TLV_SET_U16(0x0010, le_scan_window_suspend),
> -		TLV_SET_U16(0x0011, le_scan_int_discovery),
> -		TLV_SET_U16(0x0012, le_scan_window_discovery),
> -		TLV_SET_U16(0x0013, le_scan_int_adv_monitor),
> -		TLV_SET_U16(0x0014, le_scan_window_adv_monitor),
> -		TLV_SET_U16(0x0015, le_scan_int_connect),
> -		TLV_SET_U16(0x0016, le_scan_window_connect),
> -		TLV_SET_U16(0x0017, le_conn_min_interval),
> -		TLV_SET_U16(0x0018, le_conn_max_interval),
> -		TLV_SET_U16(0x0019, le_conn_latency),
> -		TLV_SET_U16(0x001a, le_supv_timeout),
> -		TLV_SET_U16_JIFFIES_TO_MSECS(0x001b,
> -					     def_le_autoconnect_timeout),
> -		TLV_SET_U16(0x001d, advmon_allowlist_duration),
> -		TLV_SET_U16(0x001e, advmon_no_filter_duration),
> -		TLV_SET_U8(0x001f, enable_advmon_interleave_scan),
> -	};
> +	} __packed rp;
> +
> +	TLV_SET_ALL();
>   
>   	bt_dev_dbg(hdev, "sock %p", sk);
>   


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ