Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit overlapping composite structs that contain flex-arrays #202

Open
GustavoARSilva opened this issue Sep 20, 2022 · 2 comments
Open

Audit overlapping composite structs that contain flex-arrays #202

GustavoARSilva opened this issue Sep 20, 2022 · 2 comments
Assignees
Labels

Comments

@GustavoARSilva
Copy link
Collaborator

GustavoARSilva commented Sep 20, 2022


NOTE (2024-04-19 - present):

I'm currently actively working on this issue.

If you want to help us with KSPP tasks, please take a look at a different issue while this note is up. :)

Thank you!


Fix all -Wflex-array-member-not-at-end warnings

When a struct containing a flexible array is included in another struct, sometimes an implicit union is created if there is a member after the struct-with-flex-array; see:

struct inner {
        ...
        int flex[];
};

struct outer {
        ...
        struct inner header;
        int overlap;
        ...
};

We need to audit all the places where this occurs and determine if the fact that instance->header.flex[0] and instance->overlap share the same memory location is intentional or if this is a legit bug.

Below is a Cocci script that can be used to spot these instances. Notice that it also identifies the case of one-element arrays. In this case, the behavior is slightly different in that the address of that type of array will not be the same as the address of the next member in the outer structure. However, if this array is actually being treated as a flexible array at run-time it might cause problems and it's worth auditing those instances, too.

@r1@
identifier foo, array;
type T;
@@

        struct foo {
                ...
(
                T array[1];
|
                T array[0];
|
                T array[];
)
        };

@@
identifier r1.foo;
identifier composite, flex, overlap;
type T;
@@

        struct composite {
                ...
*               struct foo flex;
                T overlap;
                ...
        };

the script above identifies instances where both fake (one-element and zero-length arrays) and true (C99 flexible-array member) flexible arrays are used.

Here are all the instances the script above currently identifies in next-20220920:



diff -u -p ./drivers/infiniband/core/uverbs_ioctl.c /tmp/nothing/drivers/infiniband/core/uverbs_ioctl.c
--- ./drivers/infiniband/core/uverbs_ioctl.c
+++ /tmp/nothing/drivers/infiniband/core/uverbs_ioctl.c
@@ -42,7 +42,6 @@ struct bundle_alloc_head {
 
 struct bundle_priv {
 	/* Must be first */
-	struct bundle_alloc_head alloc_head;
 	struct bundle_alloc_head *allocated_mem;
 	size_t internal_avail;
 	size_t internal_used;
diff -u -p ./drivers/staging/r8188eu/include/odm.h /tmp/nothing/drivers/staging/r8188eu/include/odm.h
--- ./drivers/staging/r8188eu/include/odm.h
+++ /tmp/nothing/drivers/staging/r8188eu/include/odm.h
@@ -205,7 +205,6 @@ struct odm_rf_cal {
 
 	u8	ThermalValue_HP[HP_THERMAL_NUM];
 	u8	ThermalValue_HP_index;
-	struct ijk_matrix_regs_set IQKMatrixRegSetting;
 
 	u8	Delta_IQK;
 	u8	Delta_LCK;
diff -u -p ./drivers/scsi/megaraid/megaraid_sas_fusion.h /tmp/nothing/drivers/scsi/megaraid/megaraid_sas_fusion.h
--- ./drivers/scsi/megaraid/megaraid_sas_fusion.h
+++ /tmp/nothing/drivers/scsi/megaraid/megaraid_sas_fusion.h
@@ -1147,7 +1147,6 @@ typedef struct LOG_BLOCK_SPAN_INFO {
 } LD_SPAN_INFO, *PLD_SPAN_INFO;
 
 struct MR_FW_RAID_MAP_ALL {
-	struct MR_FW_RAID_MAP raidMap;
 	struct MR_LD_SPAN_MAP ldSpanMap[MAX_LOGICAL_DRIVES];
 } __attribute__ ((packed));
 
@@ -1192,7 +1191,6 @@ struct MR_DRV_RAID_MAP {
  */
 struct MR_DRV_RAID_MAP_ALL {
 
-	struct MR_DRV_RAID_MAP raidMap;
 	struct MR_LD_SPAN_MAP ldSpanMap[MAX_LOGICAL_DRIVES_DYN];
 } __packed;
 
diff -u -p ./include/rdma/ib_verbs.h /tmp/nothing/include/rdma/ib_verbs.h
--- ./include/rdma/ib_verbs.h
+++ /tmp/nothing/include/rdma/ib_verbs.h
@@ -1905,7 +1905,6 @@ struct ib_flow_eth_filter {
 struct ib_flow_spec_eth {
 	u32			  type;
 	u16			  size;
-	struct ib_flow_eth_filter val;
 	struct ib_flow_eth_filter mask;
 };
 
@@ -1919,7 +1918,6 @@ struct ib_flow_ib_filter {
 struct ib_flow_spec_ib {
 	u32			 type;
 	u16			 size;
-	struct ib_flow_ib_filter val;
 	struct ib_flow_ib_filter mask;
 };
 
@@ -1944,7 +1942,6 @@ struct ib_flow_ipv4_filter {
 struct ib_flow_spec_ipv4 {
 	u32			   type;
 	u16			   size;
-	struct ib_flow_ipv4_filter val;
 	struct ib_flow_ipv4_filter mask;
 };
 
@@ -1962,7 +1959,6 @@ struct ib_flow_ipv6_filter {
 struct ib_flow_spec_ipv6 {
 	u32			   type;
 	u16			   size;
-	struct ib_flow_ipv6_filter val;
 	struct ib_flow_ipv6_filter mask;
 };
 
@@ -1976,7 +1972,6 @@ struct ib_flow_tcp_udp_filter {
 struct ib_flow_spec_tcp_udp {
 	u32			      type;
 	u16			      size;
-	struct ib_flow_tcp_udp_filter val;
 	struct ib_flow_tcp_udp_filter mask;
 };
 
@@ -1991,7 +1986,6 @@ struct ib_flow_tunnel_filter {
 struct ib_flow_spec_tunnel {
 	u32			      type;
 	u16			      size;
-	struct ib_flow_tunnel_filter  val;
 	struct ib_flow_tunnel_filter  mask;
 };
 
@@ -2005,7 +1999,6 @@ struct ib_flow_esp_filter {
 struct ib_flow_spec_esp {
 	u32                           type;
 	u16			      size;
-	struct ib_flow_esp_filter     val;
 	struct ib_flow_esp_filter     mask;
 };
 
@@ -2020,7 +2013,6 @@ struct ib_flow_gre_filter {
 struct ib_flow_spec_gre {
 	u32                           type;
 	u16			      size;
-	struct ib_flow_gre_filter     val;
 	struct ib_flow_gre_filter     mask;
 };
 
@@ -2033,7 +2025,6 @@ struct ib_flow_mpls_filter {
 struct ib_flow_spec_mpls {
 	u32                           type;
 	u16			      size;
-	struct ib_flow_mpls_filter     val;
 	struct ib_flow_mpls_filter     mask;
 };
 
diff -u -p ./fs/dlm/dlm_internal.h /tmp/nothing/fs/dlm/dlm_internal.h
--- ./fs/dlm/dlm_internal.h
+++ /tmp/nothing/fs/dlm/dlm_internal.h
@@ -612,7 +612,6 @@ struct dlm_ls {
 
 	struct dlm_rsb		ls_stub_rsb;	/* for returning errors */
 	struct dlm_lkb		ls_stub_lkb;	/* for returning errors */
-	struct dlm_message	ls_stub_ms;	/* for faking a reply */
 
 	struct dentry		*ls_debug_rsb_dentry; /* debugfs */
 	struct dentry		*ls_debug_waiters_dentry; /* debugfs */
diff -u -p ./drivers/infiniband/core/cm.c /tmp/nothing/drivers/infiniband/core/cm.c
--- ./drivers/infiniband/core/cm.c
+++ /tmp/nothing/drivers/infiniband/core/cm.c
@@ -191,7 +191,6 @@ struct cm_work {
 };
 
 struct cm_timewait_info {
-	struct cm_work work;
 	struct list_head list;
 	struct rb_node remote_qp_node;
 	struct rb_node remote_id_node;
diff -u -p ./drivers/staging/greybus/audio_apbridgea.h /tmp/nothing/drivers/staging/greybus/audio_apbridgea.h
--- ./drivers/staging/greybus/audio_apbridgea.h
+++ /tmp/nothing/drivers/staging/greybus/audio_apbridgea.h
@@ -69,26 +69,22 @@ struct audio_apbridgea_hdr {
 } __packed;
 
 struct audio_apbridgea_set_config_request {
-	struct audio_apbridgea_hdr	hdr;
 	__le32				format;	/* AUDIO_APBRIDGEA_PCM_FMT_* */
 	__le32				rate;	/* AUDIO_APBRIDGEA_PCM_RATE_* */
 	__le32				mclk_freq; /* XXX Remove? */
 } __packed;
 
 struct audio_apbridgea_register_cport_request {
-	struct audio_apbridgea_hdr	hdr;
 	__le16				cport;
 	__u8				direction;
 } __packed;
 
 struct audio_apbridgea_unregister_cport_request {
-	struct audio_apbridgea_hdr	hdr;
 	__le16				cport;
 	__u8				direction;
 } __packed;
 
 struct audio_apbridgea_set_tx_data_size_request {
-	struct audio_apbridgea_hdr	hdr;
 	__le16				size;
 } __packed;
 
@@ -97,7 +93,6 @@ struct audio_apbridgea_prepare_tx_reques
 } __packed;
 
 struct audio_apbridgea_start_tx_request {
-	struct audio_apbridgea_hdr	hdr;
 	__le64				timestamp;
 } __packed;
 
@@ -110,7 +105,6 @@ struct audio_apbridgea_shutdown_tx_reque
 } __packed;
 
 struct audio_apbridgea_set_rx_data_size_request {
-	struct audio_apbridgea_hdr	hdr;
 	__le16				size;
 } __packed;
 
diff -u -p ./drivers/staging/rtl8192u/ieee80211/ieee80211.h /tmp/nothing/drivers/staging/rtl8192u/ieee80211/ieee80211.h
--- ./drivers/staging/rtl8192u/ieee80211/ieee80211.h
+++ /tmp/nothing/drivers/staging/rtl8192u/ieee80211/ieee80211.h
@@ -955,7 +955,6 @@ struct ieee80211_info_element {
 } __packed;
 
 struct ieee80211_authentication {
-	struct rtl_80211_hdr_3addr header;
 	__le16 algorithm;
 	__le16 transaction;
 	__le16 status;
@@ -964,18 +963,15 @@ struct ieee80211_authentication {
 } __packed;
 
 struct ieee80211_disassoc {
-	struct rtl_80211_hdr_3addr header;
 	__le16 reason;
 } __packed;
 
 struct ieee80211_probe_request {
-	struct rtl_80211_hdr_3addr header;
 	/* SSID, supported rates */
 	struct ieee80211_info_element info_element[];
 } __packed;
 
 struct ieee80211_probe_response {
-	struct rtl_80211_hdr_3addr header;
 	__le32 time_stamp[2];
 	__le16 beacon_interval;
 	__le16 capability;
@@ -989,7 +985,6 @@ struct ieee80211_probe_response {
 #define ieee80211_beacon ieee80211_probe_response
 
 struct ieee80211_assoc_request_frame {
-	struct rtl_80211_hdr_3addr header;
 	__le16 capability;
 	__le16 listen_interval;
 	/* SSID, supported rates, RSN */
@@ -997,7 +992,6 @@ struct ieee80211_assoc_request_frame {
 } __packed;
 
 struct ieee80211_reassoc_request_frame {
-	struct rtl_80211_hdr_3addr header;
 	__le16 capability;
 	__le16 listen_interval;
 	u8 current_ap[ETH_ALEN];
@@ -1006,7 +1000,6 @@ struct ieee80211_reassoc_request_frame {
 } __packed;
 
 struct ieee80211_assoc_response_frame {
-	struct rtl_80211_hdr_3addr header;
 	__le16 capability;
 	__le16 status;
 	__le16 aid;
diff -u -p ./drivers/scsi/pmcraid.h /tmp/nothing/drivers/scsi/pmcraid.h
--- ./drivers/scsi/pmcraid.h
+++ /tmp/nothing/drivers/scsi/pmcraid.h
@@ -628,7 +628,6 @@ struct pmcraid_aen_msg {
 
 /* Controller state event message type */
 struct pmcraid_state_msg {
-	struct pmcraid_aen_msg msg;
 	u32 ioa_state;
 };
 
diff -u -p ./drivers/net/wireless/marvell/mwl8k.c /tmp/nothing/drivers/net/wireless/marvell/mwl8k.c
--- ./drivers/net/wireless/marvell/mwl8k.c
+++ /tmp/nothing/drivers/net/wireless/marvell/mwl8k.c
@@ -2350,7 +2350,6 @@ static void mwl8k_setup_5ghz_band(struct
  * CMD_GET_HW_SPEC (STA version).
  */
 struct mwl8k_cmd_get_hw_spec_sta {
-	struct mwl8k_cmd_pkt header;
 	__u8 hw_rev;
 	__u8 host_interface;
 	__le16 num_mcaddrs;
@@ -2499,7 +2498,6 @@ static int mwl8k_cmd_get_hw_spec_sta(str
  * CMD_GET_HW_SPEC (AP version).
  */
 struct mwl8k_cmd_get_hw_spec_ap {
-	struct mwl8k_cmd_pkt header;
 	__u8 hw_rev;
 	__u8 host_interface;
 	__le16 num_wcb;
@@ -2593,7 +2591,6 @@ done:
  * CMD_SET_HW_SPEC.
  */
 struct mwl8k_cmd_set_hw_spec {
-	struct mwl8k_cmd_pkt header;
 	__u8 hw_rev;
 	__u8 host_interface;
 	__le16 num_mcaddrs;
@@ -2670,7 +2667,6 @@ static int mwl8k_cmd_set_hw_spec(struct
  * CMD_MAC_MULTICAST_ADR.
  */
 struct mwl8k_cmd_mac_multicast_adr {
-	struct mwl8k_cmd_pkt header;
 	__le16 action;
 	__le16 numaddr;
 	__u8 addr[][ETH_ALEN];
@@ -2729,7 +2725,6 @@ __mwl8k_cmd_mac_multicast_adr(struct iee
  * CMD_GET_STAT.
  */
 struct mwl8k_cmd_get_stat {
-	struct mwl8k_cmd_pkt header;
 	__le32 stats[64];
 } __packed;
 
@@ -2771,7 +2766,6 @@ static int mwl8k_cmd_get_stat(struct iee
  * CMD_RADIO_CONTROL.
  */
 struct mwl8k_cmd_radio_control {
-	struct mwl8k_cmd_pkt header;
 	__le16 action;
 	__le16 control;
 	__le16 radio_on;
@@ -2832,7 +2826,6 @@ mwl8k_set_radio_preamble(struct ieee8021
 #define MWL8K_RF_TX_POWER_LEVEL_TOTAL	8
 
 struct mwl8k_cmd_rf_tx_power {
-	struct mwl8k_cmd_pkt header;
 	__le16 action;
 	__le16 support_level;
 	__le16 current_level;
@@ -2866,7 +2859,6 @@ static int mwl8k_cmd_rf_tx_power(struct
 #define MWL8K_TX_POWER_LEVEL_TOTAL      12
 
 struct mwl8k_cmd_tx_power {
-	struct mwl8k_cmd_pkt header;
 	__le16 action;
 	__le16 band;
 	__le16 channel;
@@ -2925,7 +2917,6 @@ static int mwl8k_cmd_tx_power(struct iee
  * CMD_RF_ANTENNA.
  */
 struct mwl8k_cmd_rf_antenna {
-	struct mwl8k_cmd_pkt header;
 	__le16 antenna;
 	__le16 mode;
 } __packed;
@@ -2958,7 +2949,6 @@ mwl8k_cmd_rf_antenna(struct ieee80211_hw
  * CMD_SET_BEACON.
  */
 struct mwl8k_cmd_set_beacon {
-	struct mwl8k_cmd_pkt header;
 	__le16 beacon_len;
 	__u8 beacon[];
 };
@@ -3013,7 +3003,6 @@ static int mwl8k_cmd_set_pre_scan(struct
  * CMD_BBP_REG_ACCESS.
  */
 struct mwl8k_cmd_bbp_reg_access {
-	struct mwl8k_cmd_pkt header;
 	__le16 action;
 	__le16 offset;
 	u8 value;
@@ -3054,7 +3043,6 @@ mwl8k_cmd_bbp_reg_access(struct ieee8021
  * CMD_SET_POST_SCAN.
  */
 struct mwl8k_cmd_set_post_scan {
-	struct mwl8k_cmd_pkt header;
 	__le32 isibss;
 	__u8 bssid[ETH_ALEN];
 } __packed;
@@ -3142,7 +3130,6 @@ static void mwl8k_update_survey(struct m
  * CMD_SET_RF_CHANNEL.
  */
 struct mwl8k_cmd_set_rf_channel {
-	struct mwl8k_cmd_pkt header;
 	__le16 action;
 	__u8 current_channel;
 	__le32 channel_flags;
@@ -3211,7 +3198,6 @@ static int mwl8k_cmd_set_rf_channel(stru
 #define MWL8K_FRAME_PROT_11N_HT_ALL			0x06
 
 struct mwl8k_cmd_update_set_aid {
-	struct	mwl8k_cmd_pkt header;
 	__le16	aid;
 
 	 /* AP's MAC address (BSSID) */
@@ -3283,7 +3269,6 @@ mwl8k_cmd_set_aid(struct ieee80211_hw *h
  * CMD_SET_RATE.
  */
 struct mwl8k_cmd_set_rate {
-	struct	mwl8k_cmd_pkt header;
 	__u8	legacy_rates[14];
 
 	/* Bitmap for supported MCS codes.  */
@@ -3319,7 +3304,6 @@ mwl8k_cmd_set_rate(struct ieee80211_hw *
 #define MWL8K_FJ_BEACON_MAXLEN	128
 
 struct mwl8k_cmd_finalize_join {
-	struct mwl8k_cmd_pkt header;
 	__le32 sleep_interval;	/* Number of beacon periods to sleep */
 	__u8 beacon_data[MWL8K_FJ_BEACON_MAXLEN];
 } __packed;
@@ -3358,7 +3342,6 @@ static int mwl8k_cmd_finalize_join(struc
  * CMD_SET_RTS_THRESHOLD.
  */
 struct mwl8k_cmd_set_rts_threshold {
-	struct mwl8k_cmd_pkt header;
 	__le16 action;
 	__le16 threshold;
 } __packed;
@@ -3388,7 +3371,6 @@ mwl8k_cmd_set_rts_threshold(struct ieee8
  * CMD_SET_SLOT.
  */
 struct mwl8k_cmd_set_slot {
-	struct mwl8k_cmd_pkt header;
 	__le16 action;
 	__u8 short_slot;
 } __packed;
@@ -3417,7 +3399,6 @@ static int mwl8k_cmd_set_slot(struct iee
  * CMD_SET_EDCA_PARAMS.
  */
 struct mwl8k_cmd_set_edca_params {
-	struct mwl8k_cmd_pkt header;
 
 	/* See MWL8K_SET_EDCA_XXX below */
 	__le16 action;
@@ -3502,7 +3483,6 @@ mwl8k_cmd_set_edca_params(struct ieee802
  * CMD_SET_WMM_MODE.
  */
 struct mwl8k_cmd_set_wmm_mode {
-	struct mwl8k_cmd_pkt header;
 	__le16 action;
 } __packed;
 
@@ -3533,7 +3513,6 @@ static int mwl8k_cmd_set_wmm_mode(struct
  * CMD_MIMO_CONFIG.
  */
 struct mwl8k_cmd_mimo_config {
-	struct mwl8k_cmd_pkt header;
 	__le32 action;
 	__u8 rx_antenna_map;
 	__u8 tx_antenna_map;
@@ -3564,7 +3543,6 @@ static int mwl8k_cmd_mimo_config(struct
  * CMD_USE_FIXED_RATE (STA version).
  */
 struct mwl8k_cmd_use_fixed_rate_sta {
-	struct mwl8k_cmd_pkt header;
 	__le32 action;
 	__le32 allow_rate_drop;
 	__le32 num_rates;
@@ -3606,7 +3584,6 @@ static int mwl8k_cmd_use_fixed_rate_sta(
  * CMD_USE_FIXED_RATE (AP version).
  */
 struct mwl8k_cmd_use_fixed_rate_ap {
-	struct mwl8k_cmd_pkt header;
 	__le32 action;
 	__le32 allow_rate_drop;
 	__le32 num_rates;
@@ -3647,7 +3624,6 @@ mwl8k_cmd_use_fixed_rate_ap(struct ieee8
  * CMD_ENABLE_SNIFFER.
  */
 struct mwl8k_cmd_enable_sniffer {
-	struct mwl8k_cmd_pkt header;
 	__le32 action;
 } __packed;
 
@@ -3756,7 +3732,6 @@ static inline int mwl8k_cmd_del_mac_addr
  * CMD_SET_RATEADAPT_MODE.
  */
 struct mwl8k_cmd_set_rate_adapt_mode {
-	struct mwl8k_cmd_pkt header;
 	__le16 action;
 	__le16 mode;
 } __packed;
@@ -3785,7 +3760,6 @@ static int mwl8k_cmd_set_rateadapt_mode(
  * CMD_GET_WATCHDOG_BITMAP.
  */
 struct mwl8k_cmd_get_watchdog_bitmap {
-	struct mwl8k_cmd_pkt header;
 	u8	bitmap;
 } __packed;
 
@@ -3865,7 +3839,6 @@ done:
  * CMD_BSS_START.
  */
 struct mwl8k_cmd_bss_start {
-	struct mwl8k_cmd_pkt header;
 	__le32 enable;
 } __packed;
 
@@ -3960,7 +3933,6 @@ struct mwl8k_destroy_ba_stream {
 } __packed;
 
 struct mwl8k_cmd_bastream {
-	struct mwl8k_cmd_pkt	header;
 	__le32	action;
 	union {
 		struct mwl8k_create_ba_stream	create_params;
@@ -4070,7 +4042,6 @@ static void mwl8k_destroy_ba(struct ieee
  * CMD_SET_NEW_STN.
  */
 struct mwl8k_cmd_set_new_stn {
-	struct mwl8k_cmd_pkt header;
 	__le16 aid;
 	__u8 mac_addr[6];
 	__le16 stn_id;
@@ -4206,7 +4177,6 @@ static int mwl8k_cmd_set_new_stn_del(str
 #define MIC_KEY_LENGTH		8
 
 struct mwl8k_cmd_update_encryption {
-	struct mwl8k_cmd_pkt header;
 
 	__le32 action;
 	__le32 reserved;
@@ -4216,7 +4186,6 @@ struct mwl8k_cmd_update_encryption {
 } __packed;
 
 struct mwl8k_cmd_set_key {
-	struct mwl8k_cmd_pkt header;
 
 	__le32 action;
 	__le32 reserved;
@@ -4504,7 +4473,6 @@ struct peer_capability_info {
 } __packed;
 
 struct mwl8k_cmd_update_stadb {
-	struct mwl8k_cmd_pkt header;
 
 	/* See STADB_ACTION_TYPE */
 	__le32	action;
diff -u -p ./drivers/net/ethernet/netronome/nfp/crypto/fw.h /tmp/nothing/drivers/net/ethernet/netronome/nfp/crypto/fw.h
--- ./drivers/net/ethernet/netronome/nfp/crypto/fw.h
+++ /tmp/nothing/drivers/net/ethernet/netronome/nfp/crypto/fw.h
@@ -55,14 +55,12 @@ struct nfp_crypto_req_add_back {
 };
 
 struct nfp_crypto_req_add_v4 {
-	struct nfp_crypto_req_add_front front;
 	__be32 src_ip;
 	__be32 dst_ip;
 	struct nfp_crypto_req_add_back back;
 };
 
 struct nfp_crypto_req_add_v6 {
-	struct nfp_crypto_req_add_front front;
 	__be32 src_ip[4];
 	__be32 dst_ip[4];
 	struct nfp_crypto_req_add_back back;
diff -u -p ./security/integrity/integrity.h /tmp/nothing/security/integrity/integrity.h
--- ./security/integrity/integrity.h
+++ /tmp/nothing/security/integrity/integrity.h
@@ -90,7 +90,6 @@ struct evm_ima_xattr_data {
 
 /* Only used in the EVM HMAC code. */
 struct evm_xattr {
-	struct evm_ima_xattr_data data;
 	u8 digest[SHA1_DIGEST_SIZE];
 } __packed;
 
@@ -118,7 +117,6 @@ struct ima_digest_data {
  * with the maximum hash size, define ima_max_digest_data struct.
  */
 struct ima_max_digest_data {
-	struct ima_digest_data hdr;
 	u8 digest[HASH_MAX_DIGESTSIZE];
 } __packed;
 
diff -u -p ./drivers/net/wireless/intel/iwlegacy/iwl-spectrum.h /tmp/nothing/drivers/net/wireless/intel/iwlegacy/iwl-spectrum.h
--- ./drivers/net/wireless/intel/iwlegacy/iwl-spectrum.h
+++ /tmp/nothing/drivers/net/wireless/intel/iwlegacy/iwl-spectrum.h
@@ -57,7 +57,6 @@ struct ieee80211_info_element {
 } __packed;
 
 struct ieee80211_measurement_request {
-	struct ieee80211_info_element ie;
 	u8 token;
 	u8 mode;
 	u8 type;
@@ -65,7 +64,6 @@ struct ieee80211_measurement_request {
 } __packed;
 
 struct ieee80211_measurement_report {
-	struct ieee80211_info_element ie;
 	u8 token;
 	u8 mode;
 	u8 type;
diff -u -p ./drivers/net/wireless/ti/wl1251/wl12xx_80211.h /tmp/nothing/drivers/net/wireless/ti/wl1251/wl12xx_80211.h
--- ./drivers/net/wireless/ti/wl1251/wl12xx_80211.h
+++ /tmp/nothing/drivers/net/wireless/ti/wl1251/wl12xx_80211.h
@@ -106,7 +106,6 @@ struct wl12xx_ie_country {
 /* Templates */
 
 struct wl12xx_beacon_template {
-	struct ieee80211_header header;
 	__le32 time_stamp[2];
 	__le16 beacon_interval;
 	__le16 capability;
@@ -129,12 +128,10 @@ struct wl12xx_ps_poll_template {
 } __packed;
 
 struct wl12xx_qos_null_data_template {
-	struct ieee80211_header header;
 	__le16 qos_ctl;
 } __packed;
 
 struct wl12xx_probe_req_template {
-	struct ieee80211_header header;
 	struct wl12xx_ie_ssid ssid;
 	struct wl12xx_ie_rates rates;
 	struct wl12xx_ie_rates ext_rates;
@@ -142,7 +139,6 @@ struct wl12xx_probe_req_template {
 
 
 struct wl12xx_probe_resp_template {
-	struct ieee80211_header header;
 	__le32 time_stamp[2];
 	__le16 beacon_interval;
 	__le16 capability;
diff -u -p ./drivers/net/ethernet/qlogic/qed/qed_hsi.h /tmp/nothing/drivers/net/ethernet/qlogic/qed/qed_hsi.h
--- ./drivers/net/ethernet/qlogic/qed/qed_hsi.h
+++ /tmp/nothing/drivers/net/ethernet/qlogic/qed/qed_hsi.h
@@ -4376,7 +4376,6 @@ struct vport_update_ramrod_mcast {
 
 /* Ramrod data for vport update ramrod */
 struct vport_update_ramrod_data {
-	struct vport_update_ramrod_data_cmn common;
 
 	struct eth_vport_rx_mode rx_mode;
 	struct eth_vport_tx_mode tx_mode;
diff -u -p ./arch/sparc/include/asm/leon_amba.h /tmp/nothing/arch/sparc/include/asm/leon_amba.h
--- ./arch/sparc/include/asm/leon_amba.h
+++ /tmp/nothing/arch/sparc/include/asm/leon_amba.h
@@ -159,8 +159,6 @@ struct amba_apbslv_device_table {
 
 struct amba_confarea_type {
 	struct amba_confarea_type *next;/* next bus in chain */
-	struct amba_device_table ahbmst;
-	struct amba_device_table ahbslv;
 	struct amba_apbslv_device_table apbslv;
 	unsigned int apbmst;
 };
diff -u -p ./include/asm-generic/hyperv-tlfs.h /tmp/nothing/include/asm-generic/hyperv-tlfs.h
--- ./include/asm-generic/hyperv-tlfs.h
+++ /tmp/nothing/include/asm-generic/hyperv-tlfs.h
@@ -469,7 +469,6 @@ struct hv_tlb_flush {
 struct hv_tlb_flush_ex {
 	u64 address_space;
 	u64 flags;
-	struct hv_vpset hv_vp_set;
 	u64 gva_list[];
 } __packed;
 
diff -u -p ./include/net/sctp/structs.h /tmp/nothing/include/net/sctp/structs.h
--- ./include/net/sctp/structs.h
+++ /tmp/nothing/include/net/sctp/structs.h
@@ -1581,7 +1581,6 @@ struct sctp_association {
 	struct sctp_endpoint *ep;
 
 	/* These are those association elements needed in the cookie.  */
-	struct sctp_cookie c;
 
 	/* This is all information about our peer.  */
 	struct {
diff -u -p ./drivers/nvme/target/loop.c /tmp/nothing/drivers/nvme/target/loop.c
--- ./drivers/nvme/target/loop.c
+++ /tmp/nothing/drivers/nvme/target/loop.c
@@ -33,7 +33,6 @@ struct nvme_loop_ctrl {
 
 	struct list_head	list;
 	struct blk_mq_tag_set	tag_set;
-	struct nvme_loop_iod	async_event_iod;
 	struct nvme_ctrl	ctrl;
 
 	struct nvmet_port	*port;
diff -u -p ./drivers/crypto/qat/qat_common/qat_crypto.h /tmp/nothing/drivers/crypto/qat/qat_common/qat_crypto.h
--- ./drivers/crypto/qat/qat_common/qat_crypto.h
+++ /tmp/nothing/drivers/crypto/qat/qat_common/qat_crypto.h
@@ -51,7 +51,6 @@ struct qat_alg_buf_list {
 } __packed;
 
 struct qat_alg_fixed_buf_list {
-	struct qat_alg_buf_list sgl_hdr;
 	struct qat_alg_buf descriptors[QAT_MAX_BUFF_DESC];
 } __packed __aligned(64);
 
diff -u -p ./drivers/crypto/nx/nx-842.h /tmp/nothing/drivers/crypto/nx/nx-842.h
--- ./drivers/crypto/nx/nx-842.h
+++ /tmp/nothing/drivers/crypto/nx/nx-842.h
@@ -171,7 +171,6 @@ struct nx842_crypto_ctx {
 	u8 *wmem;
 	u8 *sbounce, *dbounce;
 
-	struct nx842_crypto_header header;
 	struct nx842_crypto_header_group group[NX842_CRYPTO_GROUP_MAX];
 
 	struct nx842_driver *driver;
diff -u -p ./drivers/net/wireless/ti/wlcore/wl12xx_80211.h /tmp/nothing/drivers/net/wireless/ti/wlcore/wl12xx_80211.h
--- ./drivers/net/wireless/ti/wlcore/wl12xx_80211.h
+++ /tmp/nothing/drivers/net/wireless/ti/wlcore/wl12xx_80211.h
@@ -131,7 +131,6 @@ struct wl12xx_arp_rsp_template {
 } __packed;
 
 struct wl12xx_disconn_template {
-	struct ieee80211_header header;
 	__le16 disconn_reason;
 } __packed;
 
diff -u -p ./drivers/net/wireless/ti/wl18xx/conf.h /tmp/nothing/drivers/net/wireless/ti/wl18xx/conf.h
--- ./drivers/net/wireless/ti/wl18xx/conf.h
+++ /tmp/nothing/drivers/net/wireless/ti/wl18xx/conf.h
@@ -120,7 +120,6 @@ struct wl18xx_priv_conf {
 	struct wl18xx_ht_settings ht;
 
 	/* this structure is copied wholesale to FW */
-	struct wl18xx_mac_and_phy_params phy;
 
 	struct conf_ap_sleep_settings ap_sleep;
 } __packed;
diff -u -p ./include/uapi/linux/netfilter_bridge/ebtables.h /tmp/nothing/include/uapi/linux/netfilter_bridge/ebtables.h
--- ./include/uapi/linux/netfilter_bridge/ebtables.h
+++ /tmp/nothing/include/uapi/linux/netfilter_bridge/ebtables.h
@@ -160,7 +160,6 @@ struct ebt_entry_target {
 
 #define EBT_STANDARD_TARGET "standard"
 struct ebt_standard_target {
-	struct ebt_entry_target target;
 	int verdict;
 };
 
diff -u -p ./include/soc/mscc/ocelot_vcap.h /tmp/nothing/include/soc/mscc/ocelot_vcap.h
--- ./include/soc/mscc/ocelot_vcap.h
+++ /tmp/nothing/include/soc/mscc/ocelot_vcap.h
@@ -496,7 +496,6 @@ enum ocelot_vcap_key_type {
 
 struct ocelot_vcap_key_vlan {
 	struct ocelot_vcap_vid vid;    /* VLAN ID (12 bit) */
-	struct ocelot_vcap_u8  pcp;    /* PCP (3 bit) */
 	enum ocelot_vcap_bit dei;    /* DEI */
 	enum ocelot_vcap_bit tagged; /* Tagged/untagged frame */
 };
@@ -545,8 +544,6 @@ struct ocelot_vcap_key_ipv4 {
 	enum ocelot_vcap_bit ttl;      /* TTL zero */
 	enum ocelot_vcap_bit fragment; /* Fragment */
 	enum ocelot_vcap_bit options;  /* Header options */
-	struct ocelot_vcap_u8 ds;
-	struct ocelot_vcap_u8 proto;      /* Protocol */
 	struct ocelot_vcap_ipv4 sip;      /* Source IP address */
 	struct ocelot_vcap_ipv4 dip;      /* Destination IP address */
 	struct ocelot_vcap_u48 data;      /* Not UDP/TCP: IP data */
@@ -564,11 +561,9 @@ struct ocelot_vcap_key_ipv4 {
 };
 
 struct ocelot_vcap_key_ipv6 {
-	struct ocelot_vcap_u8 proto; /* IPv6 protocol */
 	struct ocelot_vcap_u128 sip; /* IPv6 source (byte 0-7 ignored) */
 	struct ocelot_vcap_u128 dip; /* IPv6 destination (byte 0-7 ignored) */
 	enum ocelot_vcap_bit ttl;  /* TTL zero */
-	struct ocelot_vcap_u8 ds;
 	struct ocelot_vcap_u48 data; /* Not UDP/TCP: IP data */
 	struct ocelot_vcap_udp_tcp sport;
 	struct ocelot_vcap_udp_tcp dport;
diff -u -p ./include/linux/mlx5/mlx5_ifc.h /tmp/nothing/include/linux/mlx5/mlx5_ifc.h
--- ./include/linux/mlx5/mlx5_ifc.h
+++ /tmp/nothing/include/linux/mlx5/mlx5_ifc.h
@@ -470,7 +470,6 @@ struct mlx5_ifc_flow_table_prop_layout_b
 
 	u8         reserved_at_c0[0x40];
 
-	struct mlx5_ifc_flow_table_fields_supported_bits ft_field_support;
 
 	struct mlx5_ifc_flow_table_fields_supported_bits ft_field_bitmask_support;
 };
@@ -1296,10 +1295,6 @@ struct mlx5_ifc_vector_calc_cap_bits {
 	u8         max_vec_count[0x8];
 	u8         reserved_at_30[0xd];
 	u8         max_chunk_size[0x3];
-	struct mlx5_ifc_calc_op calc0;
-	struct mlx5_ifc_calc_op calc1;
-	struct mlx5_ifc_calc_op calc2;
-	struct mlx5_ifc_calc_op calc3;
 
 	u8         reserved_at_c0[0x720];
 };
@@ -2306,7 +2301,6 @@ struct mlx5_ifc_resource_dump_terminate_
 struct mlx5_ifc_menu_resource_dump_response_bits {
 	struct mlx5_ifc_resource_dump_info_segment_bits info;
 	struct mlx5_ifc_resource_dump_command_segment_bits cmd;
-	struct mlx5_ifc_resource_dump_menu_segment_bits menu;
 	struct mlx5_ifc_resource_dump_terminate_segment_bits terminate;
 };
 
@@ -6356,7 +6350,6 @@ struct mlx5_ifc_modify_esw_vport_context
 	u8         reserved_at_41[0xf];
 	u8         vport_number[0x10];
 
-	struct mlx5_ifc_esw_vport_context_fields_select_bits field_select;
 
 	struct mlx5_ifc_esw_vport_context_bits esw_vport_context;
 };
@@ -6962,7 +6955,6 @@ struct mlx5_ifc_modify_tis_in_bits {
 
 	u8         reserved_at_60[0x20];
 
-	struct mlx5_ifc_modify_tis_bitmask_bits bitmask;
 
 	u8         reserved_at_c0[0x40];
 
@@ -7001,7 +6993,6 @@ struct mlx5_ifc_modify_tir_in_bits {
 
 	u8         reserved_at_60[0x20];
 
-	struct mlx5_ifc_modify_tir_bitmask_bits bitmask;
 
 	u8         reserved_at_c0[0x40];
 
@@ -7102,7 +7093,6 @@ struct mlx5_ifc_modify_rqt_in_bits {
 
 	u8         reserved_at_60[0x20];
 
-	struct mlx5_ifc_rqt_bitmask_bits bitmask;
 
 	u8         reserved_at_c0[0x40];
 
@@ -7173,7 +7163,6 @@ struct mlx5_ifc_modify_rmp_in_bits {
 
 	u8         reserved_at_60[0x20];
 
-	struct mlx5_ifc_rmp_bitmask_bits bitmask;
 
 	u8         reserved_at_c0[0x40];
 
@@ -7218,7 +7207,6 @@ struct mlx5_ifc_modify_nic_vport_context
 	u8         reserved_at_41[0xf];
 	u8         vport_number[0x10];
 
-	struct mlx5_ifc_modify_nic_vport_field_select_bits field_select;
 
 	u8         reserved_at_80[0x780];
 
diff -u -p ./drivers/atm/fore200e.h /tmp/nothing/drivers/atm/fore200e.h
--- ./drivers/atm/fore200e.h
+++ /tmp/nothing/drivers/atm/fore200e.h
@@ -440,9 +440,7 @@ typedef struct stats_aux {
 
 typedef struct stats {
     struct stats_phy   phy;      /* physical encoding statistics */
-    struct stats_oc3   oc3;      /* OC-3 statistics              */
     struct stats_atm   atm;      /* ATM statistics               */
-    struct stats_aal0  aal0;     /* AAL0 statistics              */
     struct stats_aal34 aal34;    /* AAL3/4 statistics            */
     struct stats_aal5  aal5;     /* AAL5 statistics              */
     struct stats_aux   aux;      /* auxiliary statistics         */
diff -u -p ./drivers/net/wireless/intel/iwlwifi/mei/sap.h /tmp/nothing/drivers/net/wireless/intel/iwlwifi/mei/sap.h
--- ./drivers/net/wireless/intel/iwlwifi/mei/sap.h
+++ /tmp/nothing/drivers/net/wireless/intel/iwlwifi/mei/sap.h
@@ -307,7 +307,6 @@ struct iwl_sap_hdr {
  * @val: The value of the DW.
  */
 struct iwl_sap_msg_dw {
-	struct iwl_sap_hdr hdr;
 	__le32 val;
 };
 
@@ -388,7 +387,6 @@ enum iwl_sap_scan_request {
  * @conn_info: Information about the connection.
  */
 struct iwl_sap_notif_conn_status {
-	struct iwl_sap_hdr hdr;
 	__le32 link_prot_state;
 	__le32 scan_request;
 	struct iwl_sap_notif_connection_info conn_info;
@@ -431,7 +429,6 @@ enum iwl_sap_notif_host_suspends_bitmap
  * @diff_time: TBD
  */
 struct iwl_sap_notif_country_code {
-	struct iwl_sap_hdr hdr;
 	__le16 mcc;
 	u8 source_id;
 	u8 reserved;
@@ -449,7 +446,6 @@ struct iwl_sap_notif_country_code {
  * @reserved1: For alignment.
  */
 struct iwl_sap_notif_host_link_up {
-	struct iwl_sap_hdr hdr;
 	struct iwl_sap_notif_connection_info conn_info;
 	u8 colloc_channel;
 	u8 colloc_band;
@@ -479,7 +475,6 @@ enum iwl_sap_notif_link_down_type {
  * @reason: The reason of the disconnection.
  */
 struct iwl_sap_notif_host_link_down {
-	struct iwl_sap_hdr hdr;
 	u8 type;
 	u8 reserved[2];
 	u8 reason_valid;
@@ -493,7 +488,6 @@ struct iwl_sap_notif_host_link_down {
  * @nvm_address: The MAC address as configured in the NVM.
  */
 struct iwl_sap_notif_host_nic_info {
-	struct iwl_sap_hdr hdr;
 	u8 mac_address[6];
 	u8 nvm_address[6];
 } __packed;
@@ -504,7 +498,6 @@ struct iwl_sap_notif_host_nic_info {
  * @dw: The payload.
  */
 struct iwl_sap_notif_dw {
-	struct iwl_sap_hdr hdr;
 	__le32 dw;
 } __packed;
 
@@ -514,7 +507,6 @@ struct iwl_sap_notif_dw {
  * @sar_chain_info_table: Tx power limits.
  */
 struct iwl_sap_notif_sar_limits {
-	struct iwl_sap_hdr hdr;
 	__le16 sar_chain_info_table[2][5];
 } __packed;
 
@@ -540,7 +532,6 @@ enum iwl_sap_nvm_caps {
  * @channels: The data for each channel.
  */
 struct iwl_sap_nvm {
-	struct iwl_sap_hdr hdr;
 	u8 hw_addr[6];
 	u8 n_hw_addrs;
 	u8 reserved;
@@ -702,7 +693,6 @@ struct iwl_sap_oob_filters {
  * @filters: Out of band filters.
  */
 struct iwl_sap_csme_filters {
-	struct iwl_sap_hdr hdr;
 	__le32 mode;
 	u8 mac_address[6];
 	__le16 reserved;
@@ -722,7 +712,6 @@ struct iwl_sap_csme_filters {
  * @payload: The payload of the transmitted packet.
  */
 struct iwl_sap_cb_data {
-	struct iwl_sap_hdr hdr;
 	__le32 reserved[7];
 	__le32 to_me_filt_status;
 	__le32 reserved2;
diff -u -p ./drivers/net/wireless/quantenna/qtnfmac/qlink.h /tmp/nothing/drivers/net/wireless/quantenna/qtnfmac/qlink.h
--- ./drivers/net/wireless/quantenna/qtnfmac/qlink.h
+++ /tmp/nothing/drivers/net/wireless/quantenna/qtnfmac/qlink.h
@@ -1567,7 +1567,6 @@ enum qlink_reg_rule_flags {
  * @dfs_cac_ms: DFS CAC period.
  */
 struct qlink_tlv_reg_rule {
-	struct qlink_tlv_hdr hdr;
 	__le32 start_freq_khz;
 	__le32 end_freq_khz;
 	__le32 max_bandwidth_khz;
@@ -1606,7 +1605,6 @@ enum qlink_dfs_state {
  * @channel: ieee80211 channel settings.
  */
 struct qlink_tlv_channel {
-	struct qlink_tlv_hdr hdr;
 	struct qlink_channel chan;
 } __packed;
 
@@ -1618,7 +1616,6 @@ struct qlink_tlv_channel {
  * @chan: channel definition data.
  */
 struct qlink_tlv_chandef {
-	struct qlink_tlv_hdr hdr;
 	struct qlink_chandef chdef;
 } __packed;
 
@@ -1643,7 +1640,6 @@ enum qlink_ie_set_type {
  * @ie_data: IEs data.
  */
 struct qlink_tlv_ie_set {
-	struct qlink_tlv_hdr hdr;
 	u8 type;
 	u8 flags;
 	u8 rsvd[2];
@@ -1657,7 +1653,6 @@ struct qlink_tlv_ie_set {
  * @ie_data: IEs data.
  */
 struct qlink_tlv_ext_ie {
-	struct qlink_tlv_hdr hdr;
 	u8 eid_ext;
 	u8 rsvd[3];
 	u8 ie_data[];
@@ -1678,7 +1673,6 @@ struct qlink_sband_iftype_data {
  * @iftype_data: interface type data entries.
  */
 struct qlink_tlv_iftype_data {
-	struct qlink_tlv_hdr hdr;
 	u8 n_iftype_data;
 	u8 rsvd[3];
 	struct qlink_sband_iftype_data iftype_data[];
diff -u -p ./drivers/net/wireless/ath/ath11k/dp.h /tmp/nothing/drivers/net/wireless/ath/ath11k/dp.h
--- ./drivers/net/wireless/ath/ath11k/dp.h
+++ /tmp/nothing/drivers/net/wireless/ath/ath11k/dp.h
@@ -1299,7 +1299,6 @@ struct htt_ppdu_stats_user_rate {
 			FIELD_GET(HTT_PPDU_STATS_TX_INFO_FLAGS_PEERID_M, _flags)
 
 struct htt_tx_ppdu_stats_info {
-	struct htt_tlv tlv_hdr;
 	u32 tx_success_bytes;
 	u32 tx_retry_bytes;
 	u32 tx_failed_bytes;
@@ -1358,7 +1357,6 @@ struct htt_ppdu_stats_usr_cmpltn_ack_ba_
 } __packed;
 
 struct htt_ppdu_stats_usr_cmn_array {
-	struct htt_tlv tlv_hdr;
 	u32 num_ppdu_stats;
 	/* tx_ppdu_stats_info is filled by multiple struct htt_tx_ppdu_stats_info
 	 * elements.
diff -u -p ./drivers/misc/bcm-vk/bcm_vk.h /tmp/nothing/drivers/misc/bcm-vk/bcm_vk.h
--- ./drivers/misc/bcm-vk/bcm_vk.h
+++ /tmp/nothing/drivers/misc/bcm-vk/bcm_vk.h
@@ -412,7 +412,6 @@ struct bcm_vk {
 
 	/* offset of the peer log control in BAR2 */
 	u32 peerlog_off;
-	struct bcm_vk_peer_log peerlog_info; /* record of peer log info */
 	/* offset of processing monitoring info in BAR2 */
 	u32 proc_mon_off;
 };
diff -u -p ./arch/powerpc/include/asm/hvcall.h /tmp/nothing/arch/powerpc/include/asm/hvcall.h
--- ./arch/powerpc/include/asm/hvcall.h
+++ /tmp/nothing/arch/powerpc/include/asm/hvcall.h
@@ -664,7 +664,6 @@ struct hv_get_perf_counter_info_params {
 	(HGPCI_REQ_BUFFER_SIZE - sizeof(struct hv_get_perf_counter_info_params))
 
 struct hv_gpci_request_buffer {
-	struct hv_get_perf_counter_info_params params;
 	uint8_t bytes[HGPCI_MAX_DATA_BYTES];
 } __packed;
 
diff -u -p ./usr/include/rdma/ib_user_verbs.h /tmp/nothing/usr/include/rdma/ib_user_verbs.h
--- ./usr/include/rdma/ib_user_verbs.h
+++ /tmp/nothing/usr/include/rdma/ib_user_verbs.h
@@ -433,7 +433,6 @@ struct ib_uverbs_create_cq_resp {
 };
 
 struct ib_uverbs_ex_create_cq_resp {
-	struct ib_uverbs_create_cq_resp base;
 	__u32 comp_mask;
 	__u32 response_length;
 };
@@ -641,7 +640,6 @@ struct ib_uverbs_create_qp_resp {
 };
 
 struct ib_uverbs_ex_create_qp_resp {
-	struct ib_uverbs_create_qp_resp base;
 	__u32 comp_mask;
 	__u32 response_length;
 };
@@ -737,7 +735,6 @@ struct ib_uverbs_modify_qp {
 };
 
 struct ib_uverbs_ex_modify_qp {
-	struct ib_uverbs_modify_qp base;
 	__u32	rate_limit;
 	__u32	reserved;
 };
diff -u -p ./drivers/net/wireless/realtek/rtlwifi/wifi.h /tmp/nothing/drivers/net/wireless/realtek/rtlwifi/wifi.h
--- ./drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ /tmp/nothing/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -1060,7 +1060,6 @@ struct rtl_info_element {
 } __packed;
 
 struct rtl_probe_rsp {
-	struct rtl_hdr_3addr header;
 	u32 time_stamp[2];
 	__le16 beacon_interval;
 	__le16 capability;
diff -u -p ./drivers/net/wireless/intel/ipw2x00/libipw.h /tmp/nothing/drivers/net/wireless/intel/ipw2x00/libipw.h
--- ./drivers/net/wireless/intel/ipw2x00/libipw.h
+++ /tmp/nothing/drivers/net/wireless/intel/ipw2x00/libipw.h
@@ -400,7 +400,6 @@ struct libipw_info_element {
 */
 
 struct libipw_auth {
-	struct libipw_hdr_3addr header;
 	__le16 algorithm;
 	__le16 transaction;
 	__le16 status;
@@ -417,7 +416,6 @@ struct libipw_channel_switch {
 } __packed;
 
 struct libipw_action {
-	struct libipw_hdr_3addr header;
 	u8 category;
 	u8 action;
 	union {
@@ -431,7 +429,6 @@ struct libipw_action {
 } __packed;
 
 struct libipw_disassoc {
-	struct libipw_hdr_3addr header;
 	__le16 reason;
 } __packed;
 
@@ -439,13 +436,11 @@ struct libipw_disassoc {
 #define libipw_deauth libipw_disassoc
 
 struct libipw_probe_request {
-	struct libipw_hdr_3addr header;
 	/* SSID, supported rates */
 	struct libipw_info_element info_element[];
 } __packed;
 
 struct libipw_probe_response {
-	struct libipw_hdr_3addr header;
 	__le32 time_stamp[2];
 	__le16 beacon_interval;
 	__le16 capability;
@@ -458,7 +453,6 @@ struct libipw_probe_response {
 #define libipw_beacon libipw_probe_response
 
 struct libipw_assoc_request {
-	struct libipw_hdr_3addr header;
 	__le16 capability;
 	__le16 listen_interval;
 	/* SSID, supported rates, RSN */
@@ -466,7 +460,6 @@ struct libipw_assoc_request {
 } __packed;
 
 struct libipw_reassoc_request {
-	struct libipw_hdr_3addr header;
 	__le16 capability;
 	__le16 listen_interval;
 	u8 current_ap[ETH_ALEN];
@@ -474,7 +467,6 @@ struct libipw_reassoc_request {
 } __packed;
 
 struct libipw_assoc_response {
-	struct libipw_hdr_3addr header;
 	__le16 capability;
 	__le16 status;
 	__le16 aid;
@@ -590,7 +582,6 @@ struct libipw_channel_map {
 } __packed;
 
 struct libipw_ibss_dfs {
-	struct libipw_info_element ie;
 	u8 owner[ETH_ALEN];
 	u8 recovery_interval;
 	struct libipw_channel_map channel_map[];
diff -u -p ./drivers/net/wireless/intel/iwlegacy/commands.h /tmp/nothing/drivers/net/wireless/intel/iwlegacy/commands.h
--- ./drivers/net/wireless/intel/iwlegacy/commands.h
+++ /tmp/nothing/drivers/net/wireless/intel/iwlegacy/commands.h
@@ -1193,8 +1193,6 @@ struct il3945_rx_frame_end {
  * stats.phy_count
  */
 struct il3945_rx_frame {
-	struct il3945_rx_frame_stats stats;
-	struct il3945_rx_frame_hdr hdr;
 	struct il3945_rx_frame_end end;
 } __packed;
 
@@ -2546,7 +2544,6 @@ struct il_scan_cmd {
 
 	/* For active scans (set to all-0s for passive scans).
 	 * Does not include payload.  Must specify Tx rate; no rate scaling. */
-	struct il_tx_cmd tx_cmd;
 
 	/* For directed active scans (set to all-0s otherwise) */
 	struct il_ssid_ie direct_scan[PROBE_OPTION_MAX];
@@ -2670,7 +2667,6 @@ struct il3945_tx_beacon_cmd {
 } __packed;
 
 struct il_tx_beacon_cmd {
-	struct il_tx_cmd tx;
 	__le16 tim_idx;
 	u8 tim_size;
 	u8 reserved1;
@@ -3346,7 +3342,6 @@ struct il_rx_pkt {
 	 * 13-00: RX frame size
 	 */
 	__le32 len_n_flags;
-	struct il_cmd_header hdr;
 	union {
 		struct il3945_rx_frame rx_frame;
 		struct il3945_tx_resp tx_resp;
diff -u -p ./drivers/net/wireless/wl3501.h /tmp/nothing/drivers/net/wireless/wl3501.h
--- ./drivers/net/wireless/wl3501.h
+++ /tmp/nothing/drivers/net/wireless/wl3501.h
@@ -235,7 +235,6 @@ struct iw_mgmt_info_element {
 } __packed;
 
 struct iw_mgmt_essid_pset {
-	struct iw_mgmt_info_element el;
 	u8 			    essid[IW_ESSID_MAX_SIZE];
 } __packed;
 
@@ -246,17 +245,14 @@ struct iw_mgmt_essid_pset {
 #define IW_DATA_RATE_MAX_LABELS 8
 
 struct iw_mgmt_data_rset {
-	struct iw_mgmt_info_element el;
 	u8 			    data_rate_labels[IW_DATA_RATE_MAX_LABELS];
 } __packed;
 
 struct iw_mgmt_ds_pset {
-	struct iw_mgmt_info_element el;
 	u8 			    chan;
 } __packed;
 
 struct iw_mgmt_cf_pset {
-	struct iw_mgmt_info_element el;
 	u8 			    cfp_count;
 	u8 			    cfp_period;
 	u16 			    cfp_max_duration;
@@ -264,7 +260,6 @@ struct iw_mgmt_cf_pset {
 } __packed;
 
 struct iw_mgmt_ibss_pset {
-	struct iw_mgmt_info_element el;
 	u16 			    atim_window;
 } __packed;
 
diff -u -p ./drivers/net/wireless/ti/wl1251/cmd.h /tmp/nothing/drivers/net/wireless/ti/wl1251/cmd.h
--- ./drivers/net/wireless/ti/wl1251/cmd.h
+++ /tmp/nothing/drivers/net/wireless/ti/wl1251/cmd.h
@@ -94,7 +94,6 @@ struct wl1251_cmd_header {
 } __packed;
 
 struct  wl1251_command {
-	struct wl1251_cmd_header header;
 	u8  parameters[MAX_CMD_PARAMS];
 } __packed;
 
@@ -136,7 +135,6 @@ enum {
 #define MAX_READ_SIZE 256
 
 struct cmd_read_write_memory {
-	struct wl1251_cmd_header header;
 
 	/* The address of the memory to read from or write to.*/
 	u32 addr;
@@ -214,7 +212,6 @@ struct wl1251_scan_ch_parameters {
 #define SCAN_MAX_NUM_OF_CHANNELS 16
 
 struct wl1251_cmd_scan {
-	struct wl1251_cmd_header header;
 
 	struct wl1251_scan_parameters params;
 	struct wl1251_scan_ch_parameters channels[SCAN_MAX_NUM_OF_CHANNELS];
@@ -232,7 +229,6 @@ enum {
 
 
 struct cmd_join {
-	struct wl1251_cmd_header header;
 
 	u32 bssid_lsb;
 	u16 bssid_msb;
@@ -269,7 +265,6 @@ struct cmd_join {
 } __packed;
 
 struct cmd_enabledisable_path {
-	struct wl1251_cmd_header header;
 
 	u8 channel;
 	u8 padding[3];
@@ -278,7 +273,6 @@ struct cmd_enabledisable_path {
 #define WL1251_MAX_TEMPLATE_SIZE 300
 
 struct wl1251_cmd_packet_template {
-	struct wl1251_cmd_header header;
 
 	__le16 size;
 	u8 data[];
@@ -298,7 +292,6 @@ struct wl1251_tim {
 
 /* Virtual Bit Map update */
 struct wl1251_cmd_vbm_update {
-	struct wl1251_cmd_header header;
 	__le16 len;
 	u8  padding[2];
 	struct wl1251_tim tim;
@@ -310,7 +303,6 @@ enum wl1251_cmd_ps_mode {
 };
 
 struct wl1251_cmd_ps_params {
-	struct wl1251_cmd_header header;
 
 	u8 ps_mode; /* STATION_* */
 	u8 send_null_data; /* Do we have to send NULL data packet ? */
@@ -326,7 +318,6 @@ struct wl1251_cmd_ps_params {
 } __packed;
 
 struct wl1251_cmd_trigger_scan_to {
-	struct wl1251_cmd_header header;
 
 	u32 timeout;
 } __packed;
@@ -375,7 +366,6 @@ enum wl1251_cmd_key_type {
  */
 
 struct wl1251_cmd_set_keys {
-	struct wl1251_cmd_header header;
 
 	/* Ignored for default WEP key */
 	u8 addr[ETH_ALEN];
diff -u -p ./drivers/net/ethernet/mellanox/mlx5/core/sf/mlx5_ifc_vhca_event.h /tmp/nothing/drivers/net/ethernet/mellanox/mlx5/core/sf/mlx5_ifc_vhca_event.h
--- ./drivers/net/ethernet/mellanox/mlx5/core/sf/mlx5_ifc_vhca_event.h
+++ /tmp/nothing/drivers/net/ethernet/mellanox/mlx5/core/sf/mlx5_ifc_vhca_event.h
@@ -74,7 +74,6 @@ struct mlx5_ifc_modify_vhca_state_in_bit
 	u8         reserved_at_41[0xf];
 	u8         function_id[0x10];
 
-	struct mlx5_ifc_vhca_state_field_select_bits vhca_state_field_select;
 
 	struct mlx5_ifc_vhca_state_context_bits vhca_state_context;
 };
diff -u -p ./include/asm-generic/tlb.h /tmp/nothing/include/asm-generic/tlb.h
--- ./include/asm-generic/tlb.h
+++ /tmp/nothing/include/asm-generic/tlb.h
@@ -309,7 +309,6 @@ struct mmu_gather {
 
 #ifndef CONFIG_MMU_GATHER_NO_GATHER
 	struct mmu_gather_batch *active;
-	struct mmu_gather_batch	local;
 	struct page		*__pages[MMU_GATHER_BUNDLE];
 
 #ifdef CONFIG_MMU_GATHER_PAGE_SIZE
diff -u -p ./include/linux/hyperv.h /tmp/nothing/include/linux/hyperv.h
--- ./include/linux/hyperv.h
+++ /tmp/nothing/include/linux/hyperv.h
@@ -744,7 +744,6 @@ struct vmbus_channel_msginfo {
 };
 
 struct vmbus_close_msg {
-	struct vmbus_channel_msginfo info;
 	struct vmbus_channel_close_channel msg;
 };
 
diff -u -p ./include/linux/cgroup-defs.h /tmp/nothing/include/linux/cgroup-defs.h
--- ./include/linux/cgroup-defs.h
+++ /tmp/nothing/include/linux/cgroup-defs.h
@@ -530,7 +530,6 @@ struct cgroup_root {
 	 * release. cgrp->ancestors[0] will be used overflowing into the
 	 * following field. cgrp_ancestor_storage must immediately follow.
 	 */
-	struct cgroup cgrp;
 
 	/* must follow cgrp for cgrp->ancestors[0], see above */
 	struct cgroup *cgrp_ancestor_storage;
diff -u -p ./include/net/bluetooth/hci.h /tmp/nothing/include/net/bluetooth/hci.h
--- ./include/net/bluetooth/hci.h
+++ /tmp/nothing/include/net/bluetooth/hci.h
@@ -1401,7 +1401,6 @@ struct hci_vnd_codecs {
 
 struct hci_rp_read_local_supported_codecs {
 	__u8	status;
-	struct hci_std_codecs std_codecs;
 	struct hci_vnd_codecs vnd_codecs;
 } __packed;
 
@@ -1437,7 +1436,6 @@ struct hci_vnd_codecs_v2 {
 
 struct hci_rp_read_local_supported_codecs_v2 {
 	__u8	status;
-	struct hci_std_codecs_v2 std_codecs;
 	struct hci_vnd_codecs_v2 vendor_codecs;
 } __packed;
 
diff -u -p ./drivers/rpmsg/qcom_glink_native.c /tmp/nothing/drivers/rpmsg/qcom_glink_native.c
--- ./drivers/rpmsg/qcom_glink_native.c
+++ /tmp/nothing/drivers/rpmsg/qcom_glink_native.c
@@ -48,7 +48,6 @@ struct glink_msg {
 struct glink_defer_cmd {
 	struct list_head node;
 
-	struct glink_msg msg;
 	u8 data[];
 };
 
diff -u -p ./drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h /tmp/nothing/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
--- ./drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
+++ /tmp/nothing/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
@@ -1870,7 +1870,6 @@ struct dcbx_app_priority_feature {
 /* FW structure in BE */
 struct dcbx_features {
 	/* PG feature */
-	struct dcbx_ets_feature ets;
 	/* PFC feature */
 	struct dcbx_pfc_feature pfc;
 	/* APP feature */
diff -u -p ./include/uapi/rdma/ib_user_verbs.h /tmp/nothing/include/uapi/rdma/ib_user_verbs.h
--- ./include/uapi/rdma/ib_user_verbs.h
+++ /tmp/nothing/include/uapi/rdma/ib_user_verbs.h
@@ -433,7 +433,6 @@ struct ib_uverbs_create_cq_resp {
 };
 
 struct ib_uverbs_ex_create_cq_resp {
-	struct ib_uverbs_create_cq_resp base;
 	__u32 comp_mask;
 	__u32 response_length;
 };
@@ -641,7 +640,6 @@ struct ib_uverbs_create_qp_resp {
 };
 
 struct ib_uverbs_ex_create_qp_resp {
-	struct ib_uverbs_create_qp_resp base;
 	__u32 comp_mask;
 	__u32 response_length;
 };
@@ -737,7 +735,6 @@ struct ib_uverbs_modify_qp {
 };
 
 struct ib_uverbs_ex_modify_qp {
-	struct ib_uverbs_modify_qp base;
 	__u32	rate_limit;
 	__u32	reserved;
 };
diff -u -p ./include/scsi/fc/fc_ms.h /tmp/nothing/include/scsi/fc/fc_ms.h
--- ./include/scsi/fc/fc_ms.h
+++ /tmp/nothing/include/scsi/fc/fc_ms.h
@@ -182,7 +182,6 @@ struct fc_fdmi_rpl {
  */
 struct fc_fdmi_rhba {
 	struct fc_fdmi_hba_identifier hbaid;
-	struct fc_fdmi_rpl		 port;
 	struct fs_fdmi_attrs		 hba_attrs;
 } __attribute__((__packed__));
 
diff -u -p ./net/smc/smc_clc.h /tmp/nothing/net/smc/smc_clc.h
--- ./net/smc/smc_clc.h
+++ /tmp/nothing/net/smc/smc_clc.h
@@ -170,9 +170,7 @@ struct smc_clc_msg_proposal_area {
 	struct smc_clc_msg_smcd			pclc_smcd;
 	struct smc_clc_msg_proposal_prefix	pclc_prfx;
 	struct smc_clc_ipv6_prefix	pclc_prfx_ipv6[SMC_CLC_MAX_V6_PREFIX];
-	struct smc_clc_v2_extension		pclc_v2_ext;
 	u8			user_eids[SMC_CLC_MAX_UEID][SMC_MAX_EID_LEN];
-	struct smc_clc_smcd_v2_extension	pclc_smcd_v2_ext;
 	struct smc_clc_smcd_gid_chid		pclc_gidchids[SMC_MAX_ISM_DEVS];
 	struct smc_clc_msg_trail		pclc_trl;
 };
diff -u -p ./drivers/staging/rtl8192e/rtllib.h /tmp/nothing/drivers/staging/rtl8192e/rtllib.h
--- ./drivers/staging/rtl8192e/rtllib.h
+++ /tmp/nothing/drivers/staging/rtl8192e/rtllib.h
@@ -797,7 +797,6 @@ struct rtllib_info_element {
 } __packed;
 
 struct rtllib_authentication {
-	struct rtllib_hdr_3addr header;
 	__le16 algorithm;
 	__le16 transaction;
 	__le16 status;
@@ -806,23 +805,19 @@ struct rtllib_authentication {
 } __packed;
 
 struct rtllib_disauth {
-	struct rtllib_hdr_3addr header;
 	__le16 reason;
 } __packed;
 
 struct rtllib_disassoc {
-	struct rtllib_hdr_3addr header;
 	__le16 reason;
 } __packed;
 
 struct rtllib_probe_request {
-	struct rtllib_hdr_3addr header;
 	/* SSID, supported rates */
 	struct rtllib_info_element info_element[];
 } __packed;
 
 struct rtllib_probe_response {
-	struct rtllib_hdr_3addr header;
 	u32 time_stamp[2];
 	__le16 beacon_interval;
 	__le16 capability;
@@ -836,7 +831,6 @@ struct rtllib_probe_response {
 #define rtllib_beacon rtllib_probe_response
 
 struct rtllib_assoc_request_frame {
-	struct rtllib_hdr_3addr header;
 	__le16 capability;
 	__le16 listen_interval;
 	/* SSID, supported rates, RSN */
@@ -844,7 +838,6 @@ struct rtllib_assoc_request_frame {
 } __packed;
 
 struct rtllib_assoc_response_frame {
-	struct rtllib_hdr_3addr header;
 	__le16 capability;
 	__le16 status;
 	__le16 aid;
diff -u -p ./drivers/scsi/qla4xxx/ql4_def.h /tmp/nothing/drivers/scsi/qla4xxx/ql4_def.h
--- ./drivers/scsi/qla4xxx/ql4_def.h
+++ /tmp/nothing/drivers/scsi/qla4xxx/ql4_def.h
@@ -548,7 +548,6 @@ struct ql4_boot_session_info {
 };
 
 struct ql4_boot_tgt_info {
-	struct ql4_boot_session_info boot_pri_sess;
 	struct ql4_boot_session_info boot_sec_sess;
 };
 
diff -u -p ./drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h /tmp/nothing/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
--- ./drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
+++ /tmp/nothing/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
@@ -345,7 +345,6 @@ struct dsaf_device {
 	struct dsaf_misc_op *misc_op;
 
 	struct dsaf_hw_stats hw_stats[DSAF_NODE_NUM];
-	struct dsaf_int_stat int_stat;
 	/* make sure tcam table config spinlock */
 	spinlock_t tcam_lock;
 };
diff -u -p ./lib/bch.c /tmp/nothing/lib/bch.c
--- ./lib/bch.c
+++ /tmp/nothing/lib/bch.c
@@ -110,7 +110,6 @@ struct gf_poly {
 
 /* polynomial of degree 1 */
 struct gf_poly_deg1 {
-	struct gf_poly poly;
 	unsigned int   c[2];
 };
 
diff -u -p ./include/uapi/linux/netfilter_ipv6/ip6_tables.h /tmp/nothing/include/uapi/linux/netfilter_ipv6/ip6_tables.h
--- ./include/uapi/linux/netfilter_ipv6/ip6_tables.h
+++ /tmp/nothing/include/uapi/linux/netfilter_ipv6/ip6_tables.h
@@ -130,12 +130,10 @@ struct ip6t_entry {
 
 /* Standard entry */
 struct ip6t_standard {
-	struct ip6t_entry entry;
 	struct xt_standard_target target;
 };
 
 struct ip6t_error {
-	struct ip6t_entry entry;
 	struct xt_error_target target;
 };
 
diff -u -p ./net/sched/sch_atm.c /tmp/nothing/net/sched/sch_atm.c
--- ./net/sched/sch_atm.c
+++ /tmp/nothing/net/sched/sch_atm.c
@@ -62,7 +62,6 @@ struct atm_flow_data {
 };
 
 struct atm_qdisc_data {
-	struct atm_flow_data	link;		/* unclassified skbs go here */
 	struct list_head	flows;		/* NB: "link" is also on this
 						   list */
 	struct tasklet_struct	task;		/* dequeue tasklet */
diff -u -p ./drivers/net/wireless/ti/wlcore/cmd.h /tmp/nothing/drivers/net/wireless/ti/wlcore/cmd.h
--- ./drivers/net/wireless/ti/wlcore/cmd.h
+++ /tmp/nothing/drivers/net/wireless/ti/wlcore/cmd.h
@@ -215,7 +215,6 @@ struct wl1271_cmd_header {
 #define WL1271_CMD_MAX_PARAMS 572
 
 struct wl1271_command {
-	struct wl1271_cmd_header header;
 	u8  parameters[WL1271_CMD_MAX_PARAMS];
 } __packed;
 
@@ -255,7 +254,6 @@ enum {
 #define WL1271_JOIN_CMD_BSS_TYPE_5GHZ 0x10
 
 struct wl12xx_cmd_role_enable {
-	struct wl1271_cmd_header header;
 
 	u8 role_id;
 	u8 role_type;
@@ -263,7 +261,6 @@ struct wl12xx_cmd_role_enable {
 } __packed;
 
 struct wl12xx_cmd_role_disable {
-	struct wl1271_cmd_header header;
 
 	u8 role_id;
 	u8 padding[3];
@@ -286,7 +283,6 @@ enum wlcore_channel_type {
 };
 
 struct wl12xx_cmd_role_start {
-	struct wl1271_cmd_header header;
 
 	u8 role_id;
 	u8 band;
@@ -376,7 +372,6 @@ struct wl12xx_cmd_role_start {
 } __packed;
 
 struct wl12xx_cmd_role_stop {
-	struct wl1271_cmd_header header;
 
 	u8 role_id;
 	u8 disc_type; /* only STA and P2P_CLI */
@@ -384,7 +379,6 @@ struct wl12xx_cmd_role_stop {
 } __packed;
 
 struct cmd_enabledisable_path {
-	struct wl1271_cmd_header header;
 
 	u8 channel;
 	u8 padding[3];
@@ -393,7 +387,6 @@ struct cmd_enabledisable_path {
 #define WL1271_RATE_AUTOMATIC  0
 
 struct wl1271_cmd_template_set {
-	struct wl1271_cmd_header header;
 
 	u8 role_id;
 	u8 template_type;
@@ -429,7 +422,6 @@ enum wl1271_cmd_ps_mode {
 };
 
 struct wl1271_cmd_ps_params {
-	struct wl1271_cmd_header header;
 
 	u8 role_id;
 	u8 ps_mode; /* STATION_* */
@@ -461,7 +453,6 @@ enum wl1271_cmd_key_type {
 };
 
 struct wl1271_cmd_set_keys {
-	struct wl1271_cmd_header header;
 
 	/*
 	 * Indicates whether the HLID is a unicast key set
@@ -536,7 +527,6 @@ enum wl1271_disconnect_type {
 #define WL1271_CMD_STA_STATE_CONNECTED  1
 
 struct wl12xx_cmd_set_peer_state {
-	struct wl1271_cmd_header header;
 
 	u8 hlid;
 	u8 state;
@@ -551,7 +541,6 @@ struct wl12xx_cmd_set_peer_state {
 } __packed;
 
 struct wl12xx_cmd_roc {
-	struct wl1271_cmd_header header;
 
 	u8 role_id;
 	u8 channel;
@@ -560,7 +549,6 @@ struct wl12xx_cmd_roc {
 };
 
 struct wl12xx_cmd_croc {
-	struct wl1271_cmd_header header;
 
 	u8 role_id;
 	u8 padding[3];
@@ -580,7 +568,6 @@ enum wl1271_psd_type {
 };
 
 struct wl12xx_cmd_add_peer {
-	struct wl1271_cmd_header header;
 
 	u8 addr[ETH_ALEN];
 	u8 hlid;
@@ -596,7 +583,6 @@ struct wl12xx_cmd_add_peer {
 } __packed;
 
 struct wl12xx_cmd_remove_peer {
-	struct wl1271_cmd_header header;
 
 	u8 hlid;
 	u8 reason_opcode;
@@ -631,7 +617,6 @@ enum wl12xx_fwlogger_output {
 };
 
 struct wl12xx_cmd_regdomain_dfs_config {
-	struct wl1271_cmd_header header;
 
 	__le32 ch_bit_map1;
 	__le32 ch_bit_map2;
@@ -644,7 +629,6 @@ enum wlcore_generic_cfg_feature {
 };
 
 struct wlcore_cmd_generic_cfg {
-	struct wl1271_cmd_header header;
 
 	u8 role_id;
 	u8 feature;
@@ -653,7 +637,6 @@ struct wlcore_cmd_generic_cfg {
 } __packed;
 
 struct wl12xx_cmd_config_fwlog {
-	struct wl1271_cmd_header header;
 
 	/* See enum wl12xx_fwlogger_log_mode */
 	u8 logger_mode;
@@ -682,7 +665,6 @@ struct wl12xx_cmd_stop_fwlog {
 } __packed;
 
 struct wl12xx_cmd_stop_channel_switch {
-	struct wl1271_cmd_header header;
 
 	u8 role_id;
 	u8 padding[3];
@@ -693,7 +675,6 @@ struct wl12xx_cmd_stop_channel_switch {
 #define TEST_CMD_P2G_CAL	2	/* TX BiP */
 
 struct wl1271_cmd_cal_p2g {
-	struct wl1271_cmd_header header;
 
 	struct wl1271_cmd_test_header test;
 
diff -u -p ./drivers/net/ethernet/qlogic/qed/qed_mfw_hsi.h /tmp/nothing/drivers/net/ethernet/qlogic/qed/qed_mfw_hsi.h
--- ./drivers/net/ethernet/qlogic/qed/qed_mfw_hsi.h
+++ /tmp/nothing/drivers/net/ethernet/qlogic/qed/qed_mfw_hsi.h
@@ -628,7 +628,6 @@ struct public_port {
 
 	u32 stat_nig_timer;
 
-	struct port_mf_cfg port_mf_config;
 	struct port_stats stats;
 
 	u32 media_type;
diff -u -p ./drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c /tmp/nothing/drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c
--- ./drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c
+++ /tmp/nothing/drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c
@@ -55,19 +55,16 @@ struct nfp_dump_common_cpp {
 
 /* CSR dumpables */
 struct nfp_dumpspec_csr {
-	struct nfp_dump_tl tl;
 	struct nfp_dump_common_cpp cpp;
 	__be32 register_width;	/* in bits */
 };
 
 struct nfp_dumpspec_rtsym {
-	struct nfp_dump_tl tl;
 	char rtsym[];
 };
 
 /* header for register dumpable */
 struct nfp_dump_csr {
-	struct nfp_dump_tl tl;
 	struct nfp_dump_common_cpp cpp;
 	__be32 register_width;	/* in bits */
 	__be32 error;		/* error code encountered while reading */
@@ -75,7 +72,6 @@ struct nfp_dump_csr {
 };
 
 struct nfp_dump_rtsym {
-	struct nfp_dump_tl tl;
 	struct nfp_dump_common_cpp cpp;
 	__be32 error;		/* error code encountered while reading */
 	u8 padded_name_length;	/* pad so data starts at 8 byte boundary */
@@ -84,12 +80,10 @@ struct nfp_dump_rtsym {
 };
 
 struct nfp_dump_prolog {
-	struct nfp_dump_tl tl;
 	__be32 dump_level;
 };
 
 struct nfp_dump_error {
-	struct nfp_dump_tl tl;
 	__be32 error;
 	char padding[4];
 	char spec[];
diff -u -p ./drivers/misc/mei/hw.h /tmp/nothing/drivers/misc/mei/hw.h
--- ./drivers/misc/mei/hw.h
+++ /tmp/nothing/drivers/misc/mei/hw.h
@@ -265,7 +265,6 @@ struct mei_ext_meta_hdr {
  * @reserved: reserved
  */
 struct mei_ext_hdr_vtag {
-	struct mei_ext_hdr hdr;
 	u8 vtag;
 	u8 reserved;
 } __packed;
diff -u -p ./arch/powerpc/platforms/powermac/nvram.c /tmp/nothing/arch/powerpc/platforms/powermac/nvram.c
--- ./arch/powerpc/platforms/powermac/nvram.c
+++ /tmp/nothing/arch/powerpc/platforms/powermac/nvram.c
@@ -59,7 +59,6 @@ struct chrp_header {
 };
 
 struct core99_header {
-  struct chrp_header	hdr;
   u32			adler;
   u32			generation;
   u32			reserved[2];
diff -u -p ./include/linux/tty_buffer.h /tmp/nothing/include/linux/tty_buffer.h
--- ./include/linux/tty_buffer.h
+++ /tmp/nothing/include/linux/tty_buffer.h
@@ -40,7 +40,6 @@ struct tty_bufhead {
 	struct work_struct work;
 	struct mutex	   lock;
 	atomic_t	   priority;
-	struct tty_buffer sentinel;
 	struct llist_head free;		/* Free queue head */
 	atomic_t	   mem_used;    /* In-use buffers excluding free list */
 	int		   mem_limit;
diff -u -p ./fs/smbfs_common/smb2pdu.h /tmp/nothing/fs/smbfs_common/smb2pdu.h
--- ./fs/smbfs_common/smb2pdu.h
+++ /tmp/nothing/fs/smbfs_common/smb2pdu.h
@@ -1158,7 +1158,6 @@ struct smb2_create_rsp {
 } __packed;
 
 struct create_posix {
-	struct create_context ccontext;
 	__u8    Name[16];
 	__le32  Mode;
 	__u32   Reserved;
@@ -1191,13 +1190,11 @@ struct lease_context_v2 {
 } __packed;
 
 struct create_lease {
-	struct create_context ccontext;
 	__u8   Name[8];
 	struct lease_context lcontext;
 } __packed;
 
 struct create_lease_v2 {
-	struct create_context ccontext;
 	__u8   Name[8];
 	struct lease_context_v2 lcontext;
 	__u8   Pad[4];
diff -u -p ./usr/include/linux/netfilter_bridge/ebtables.h /tmp/nothing/usr/include/linux/netfilter_bridge/ebtables.h
--- ./usr/include/linux/netfilter_bridge/ebtables.h
+++ /tmp/nothing/usr/include/linux/netfilter_bridge/ebtables.h
@@ -160,7 +160,6 @@ struct ebt_entry_target {
 
 #define EBT_STANDARD_TARGET "standard"
 struct ebt_standard_target {
-	struct ebt_entry_target target;
 	int verdict;
 };
 
diff -u -p ./drivers/scsi/esas2r/atvda.h /tmp/nothing/drivers/scsi/esas2r/atvda.h
--- ./drivers/scsi/esas2r/atvda.h
+++ /tmp/nothing/drivers/scsi/esas2r/atvda.h
@@ -187,7 +187,6 @@ struct __packed atto_vda_sge {
 #define VDA_IOCTL_SMP     0x02
 
 struct __packed atto_vda_devinfo {
-	struct atto_dev_addr dev_addr;
 	u8 vendor_id[8];
 	u8 product_id[16];
 	u8 revision[4];
@@ -284,7 +283,6 @@ struct __packed atto_vda_devinfo {
  */
 
 struct __packed atto_vda_devinfo2 {
-	struct atto_dev_addr dev_addr;
 	u8 vendor_id[8];
 	u8 product_id[16];
 	u8 revision[4];
diff -u -p ./include/uapi/linux/netfilter/x_tables.h /tmp/nothing/include/uapi/linux/netfilter/x_tables.h
--- ./include/uapi/linux/netfilter/x_tables.h
+++ /tmp/nothing/include/uapi/linux/netfilter/x_tables.h
@@ -63,12 +63,10 @@ struct xt_entry_target {
 }
 
 struct xt_standard_target {
-	struct xt_entry_target target;
 	int verdict;
 };
 
 struct xt_error_target {
-	struct xt_entry_target target;
 	char errorname[XT_FUNCTION_MAXNAMELEN];
 };
 
diff -u -p ./include/linux/bpf.h /tmp/nothing/include/linux/bpf.h
--- ./include/linux/bpf.h
+++ /tmp/nothing/include/linux/bpf.h
@@ -1472,7 +1472,6 @@ struct bpf_prog_array {
 };
 
 struct bpf_empty_prog_array {
-	struct bpf_prog_array hdr;
 	struct bpf_prog *null_prog;
 };
 
diff -u -p ./drivers/nfc/pn533/usb.c /tmp/nothing/drivers/nfc/pn533/usb.c
--- ./drivers/nfc/pn533/usb.c
+++ /tmp/nothing/drivers/nfc/pn533/usb.c
@@ -250,14 +250,12 @@ struct pn533_acr122_apdu_hdr {
 } __packed;
 
 struct pn533_acr122_tx_frame {
-	struct pn533_acr122_ccid_hdr ccid;
 	struct pn533_acr122_apdu_hdr apdu;
 	u8 datalen;
 	u8 data[]; /* pn533 frame: TFI ... */
 } __packed;
 
 struct pn533_acr122_rx_frame {
-	struct pn533_acr122_ccid_hdr ccid;
 	u8 data[]; /* pn533 frame : TFI ... */
 } __packed;
 
diff -u -p ./include/net/nfc/nci.h /tmp/nothing/include/net/nfc/nci.h
--- ./include/net/nfc/nci.h
+++ /tmp/nothing/include/net/nfc/nci.h
@@ -552,7 +552,6 @@ struct nci_nfcee_information_tlv {
 struct nci_nfcee_discover_ntf {
 	__u8	nfcee_id;
 	__u8	nfcee_status;
-	struct nci_nfcee_supported_protocol supported_protocols;
 	struct nci_nfcee_information_tlv	information_tlv;
 } __packed;
 
diff -u -p ./usr/include/linux/netfilter_ipv6/ip6_tables.h /tmp/nothing/usr/include/linux/netfilter_ipv6/ip6_tables.h
--- ./usr/include/linux/netfilter_ipv6/ip6_tables.h
+++ /tmp/nothing/usr/include/linux/netfilter_ipv6/ip6_tables.h
@@ -128,12 +128,10 @@ struct ip6t_entry {
 
 /* Standard entry */
 struct ip6t_standard {
-	struct ip6t_entry entry;
 	struct xt_standard_target target;
 };
 
 struct ip6t_error {
-	struct ip6t_entry entry;
 	struct xt_error_target target;
 };
 
diff -u -p ./usr/include/linux/netfilter/x_tables.h /tmp/nothing/usr/include/linux/netfilter/x_tables.h
--- ./usr/include/linux/netfilter/x_tables.h
+++ /tmp/nothing/usr/include/linux/netfilter/x_tables.h
@@ -63,12 +63,10 @@ struct xt_entry_target {
 }
 
 struct xt_standard_target {
-	struct xt_entry_target target;
 	int verdict;
 };
 
 struct xt_error_target {
-	struct xt_entry_target target;
 	char errorname[XT_FUNCTION_MAXNAMELEN];
 };
 
@GustavoARSilva GustavoARSilva self-assigned this Sep 20, 2022
@kees
Copy link

kees commented Sep 21, 2022

It seems like overlapping with a matching type is okay (in the sense that an implicit union has been created). I wonder if the non-matching type throws an error with the compiler? It's not clear to me if either case should be considered a problem...

@GustavoARSilva
Copy link
Collaborator Author

It seems like overlapping with a matching type is okay (in the sense that an implicit union has been created). I wonder if the non-matching type throws an error with the compiler? It's not clear to me if either case should be considered a problem...

Yep; I'll look into that. :)

jonhunter pushed a commit to jonhunter/linux that referenced this issue Mar 7, 2024
…bridgea_hdr

When a struct containing a flexible array is included in another struct,
and there is a member after the struct-with-flex-array, there is a
possibility of memory overlap. These cases must be audited [1]. See:

struct inner {
	...
	int flex[];
};

struct outer {
	...
	struct inner header;
	int overlap;
	...
};

This is the scenario for the "struct audio_apbridgea_hdr" structure
that is included in the following "struct audio_apbridgea_*_request"
structures:

struct audio_apbridgea_set_config_request
struct audio_apbridgea_register_cport_request
struct audio_apbridgea_unregister_cport_request
struct audio_apbridgea_set_tx_data_size_request
struct audio_apbridgea_prepare_tx_request
struct audio_apbridgea_start_tx_request
struct audio_apbridgea_stop_tx_request
struct audio_apbridgea_shutdown_tx_request
struct audio_apbridgea_set_rx_data_size_request
struct audio_apbridgea_prepare_rx_request
struct audio_apbridgea_start_rx_request
struct audio_apbridgea_stop_rx_request
struct audio_apbridgea_shutdown_rx_request

The pattern is like the one shown below:

struct audio_apbridgea_hdr {
	...
	__u8 data[];
} __packed;

struct audio_apbridgea_*_request {
	struct audio_apbridgea_hdr hdr;
	...
} __packed;

In this case, the trailing flexible array can be removed because it is
never used.

Link: KSPP#202 [1]
Signed-off-by: Erick Archer <erick.archer@gmx.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Link: https://lore.kernel.org/r/20240217154758.7965-1-erick.archer@gmx.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tiwai pushed a commit to tiwai/sound that referenced this issue Mar 26, 2024
Use the `DEFINE_FLEX()` helper for an on-stack definition of a
flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

So, with these changes, fix the following warning:
sound/firewire/amdtp-stream.c:1184:46: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: KSPP#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Message-ID: <ZgIsBqoMb7p3fMDr@neat>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
github-actions bot pushed a commit to tedd-an/bluetooth-next that referenced this issue Mar 26, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

There are currently a couple of objects (`req` and `rsp`), in a couple
of structures, that contain flexible structures (`struct l2cap_ecred_conn_req`
and `struct l2cap_ecred_conn_rsp`), for example:

struct l2cap_ecred_rsp_data {
        struct {
                struct l2cap_ecred_conn_rsp rsp;
                __le16 scid[L2CAP_ECRED_MAX_CID];
        } __packed pdu;
        int count;
};

in the struct above, `struct l2cap_ecred_conn_rsp` is a flexible
structure:

struct l2cap_ecred_conn_rsp {
        __le16 mtu;
        __le16 mps;
        __le16 credits;
        __le16 result;
        __le16 dcid[];
};

So, in order to avoid ending up with a flexible-array member in the
middle of another structure, we use the `struct_group_tagged()` (and
`__struct_group()` when the flexible structure is `__packed`) helper
to separate the flexible array from the rest of the members in the
flexible structure:

struct l2cap_ecred_conn_rsp {
        struct_group_tagged(l2cap_ecred_conn_rsp_hdr, hdr,

	... the rest of members

        );
        __le16 dcid[];
};

With the change described above, we now declare objects of the type of
the tagged struct, in this example `struct l2cap_ecred_conn_rsp_hdr`,
without embedding flexible arrays in the middle of other structures:

struct l2cap_ecred_rsp_data {
        struct {
                struct l2cap_ecred_conn_rsp_hdr rsp;
                __le16 scid[L2CAP_ECRED_MAX_CID];
        } __packed pdu;
        int count;
};

Also, when the flexible-array member needs to be accessed, we use
`container_of()` to retrieve a pointer to the flexible structure.

We also use the `DEFINE_RAW_FLEX()` helper for a couple of on-stack
definitions of a flexible structure where the size of the flexible-array
member is known at compile-time.

So, with these changes, fix the following warnings:
net/bluetooth/l2cap_core.c:1260:45: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:3740:45: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:4999:45: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:7116:47: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
github-actions bot pushed a commit to BluezTestBot/bluetooth-next that referenced this issue Mar 26, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

There are currently a couple of objects (`req` and `rsp`), in a couple
of structures, that contain flexible structures (`struct l2cap_ecred_conn_req`
and `struct l2cap_ecred_conn_rsp`), for example:

struct l2cap_ecred_rsp_data {
        struct {
                struct l2cap_ecred_conn_rsp rsp;
                __le16 scid[L2CAP_ECRED_MAX_CID];
        } __packed pdu;
        int count;
};

in the struct above, `struct l2cap_ecred_conn_rsp` is a flexible
structure:

struct l2cap_ecred_conn_rsp {
        __le16 mtu;
        __le16 mps;
        __le16 credits;
        __le16 result;
        __le16 dcid[];
};

So, in order to avoid ending up with a flexible-array member in the
middle of another structure, we use the `struct_group_tagged()` (and
`__struct_group()` when the flexible structure is `__packed`) helper
to separate the flexible array from the rest of the members in the
flexible structure:

struct l2cap_ecred_conn_rsp {
        struct_group_tagged(l2cap_ecred_conn_rsp_hdr, hdr,

	... the rest of members

        );
        __le16 dcid[];
};

With the change described above, we now declare objects of the type of
the tagged struct, in this example `struct l2cap_ecred_conn_rsp_hdr`,
without embedding flexible arrays in the middle of other structures:

struct l2cap_ecred_rsp_data {
        struct {
                struct l2cap_ecred_conn_rsp_hdr rsp;
                __le16 scid[L2CAP_ECRED_MAX_CID];
        } __packed pdu;
        int count;
};

Also, when the flexible-array member needs to be accessed, we use
`container_of()` to retrieve a pointer to the flexible structure.

We also use the `DEFINE_RAW_FLEX()` helper for a couple of on-stack
definitions of a flexible structure where the size of the flexible-array
member is known at compile-time.

So, with these changes, fix the following warnings:
net/bluetooth/l2cap_core.c:1260:45: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:3740:45: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:4999:45: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:7116:47: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
jonhunter pushed a commit to jonhunter/linux that referenced this issue Mar 27, 2024
Use the `DEFINE_FLEX()` helper for an on-stack definition of a
flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

So, with these changes, fix the following warning:
fs/notify/fdinfo.c:45:36: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: KSPP#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Message-Id: <ZgImguNzJBiis9Mj@neat>
github-actions bot pushed a commit to BluezTestBot/bluetooth-next that referenced this issue Mar 27, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

There are currently a couple of objects (`req` and `rsp`), in a couple
of structures, that contain flexible structures (`struct l2cap_ecred_conn_req`
and `struct l2cap_ecred_conn_rsp`), for example:

struct l2cap_ecred_rsp_data {
        struct {
                struct l2cap_ecred_conn_rsp rsp;
                __le16 scid[L2CAP_ECRED_MAX_CID];
        } __packed pdu;
        int count;
};

in the struct above, `struct l2cap_ecred_conn_rsp` is a flexible
structure:

struct l2cap_ecred_conn_rsp {
        __le16 mtu;
        __le16 mps;
        __le16 credits;
        __le16 result;
        __le16 dcid[];
};

So, in order to avoid ending up with a flexible-array member in the
middle of another structure, we use the `struct_group_tagged()` (and
`__struct_group()` when the flexible structure is `__packed`) helper
to separate the flexible array from the rest of the members in the
flexible structure:

struct l2cap_ecred_conn_rsp {
        struct_group_tagged(l2cap_ecred_conn_rsp_hdr, hdr,

	... the rest of members

        );
        __le16 dcid[];
};

With the change described above, we now declare objects of the type of
the tagged struct, in this example `struct l2cap_ecred_conn_rsp_hdr`,
without embedding flexible arrays in the middle of other structures:

struct l2cap_ecred_rsp_data {
        struct {
                struct l2cap_ecred_conn_rsp_hdr rsp;
                __le16 scid[L2CAP_ECRED_MAX_CID];
        } __packed pdu;
        int count;
};

Also, when the flexible-array member needs to be accessed, we use
`container_of()` to retrieve a pointer to the flexible structure.

We also use the `DEFINE_RAW_FLEX()` helper for a couple of on-stack
definitions of a flexible structure where the size of the flexible-array
member is known at compile-time.

So, with these changes, fix the following warnings:
net/bluetooth/l2cap_core.c:1260:45: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:3740:45: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:4999:45: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:7116:47: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
github-actions bot pushed a commit to tedd-an/bluetooth-next that referenced this issue Mar 27, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

There are currently a couple of objects (`req` and `rsp`), in a couple
of structures, that contain flexible structures (`struct l2cap_ecred_conn_req`
and `struct l2cap_ecred_conn_rsp`), for example:

struct l2cap_ecred_rsp_data {
        struct {
                struct l2cap_ecred_conn_rsp rsp;
                __le16 scid[L2CAP_ECRED_MAX_CID];
        } __packed pdu;
        int count;
};

in the struct above, `struct l2cap_ecred_conn_rsp` is a flexible
structure:

struct l2cap_ecred_conn_rsp {
        __le16 mtu;
        __le16 mps;
        __le16 credits;
        __le16 result;
        __le16 dcid[];
};

So, in order to avoid ending up with a flexible-array member in the
middle of another structure, we use the `struct_group_tagged()` (and
`__struct_group()` when the flexible structure is `__packed`) helper
to separate the flexible array from the rest of the members in the
flexible structure:

struct l2cap_ecred_conn_rsp {
        struct_group_tagged(l2cap_ecred_conn_rsp_hdr, hdr,

	... the rest of members

        );
        __le16 dcid[];
};

With the change described above, we now declare objects of the type of
the tagged struct, in this example `struct l2cap_ecred_conn_rsp_hdr`,
without embedding flexible arrays in the middle of other structures:

struct l2cap_ecred_rsp_data {
        struct {
                struct l2cap_ecred_conn_rsp_hdr rsp;
                __le16 scid[L2CAP_ECRED_MAX_CID];
        } __packed pdu;
        int count;
};

Also, when the flexible-array member needs to be accessed, we use
`container_of()` to retrieve a pointer to the flexible structure.

We also use the `DEFINE_RAW_FLEX()` helper for a couple of on-stack
definitions of a flexible structure where the size of the flexible-array
member is known at compile-time.

So, with these changes, fix the following warnings:
net/bluetooth/l2cap_core.c:1260:45: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:3740:45: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:4999:45: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:7116:47: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
jonhunter pushed a commit to jonhunter/linux that referenced this issue Mar 28, 2024
…warnings

Use the `DEFINE_RAW_FLEX()` helper for an on-stack definition of
a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

So, with these changes, fix the following warning:
drivers/platform/chrome/cros_ec_proto_test.c:1547:40: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/platform/chrome/cros_ec_proto_test.c:1607:40: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/platform/chrome/cros_ec_proto_test.c:1645:40: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/platform/chrome/cros_ec_proto_test.c:1668:40: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: KSPP#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/ZgMaDl/of8YC445S@neat
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
ryno-swart-corigine pushed a commit to Corigine/nfp-drv-kmods that referenced this issue Apr 3, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

There is currently an object (`tl`), at the beginning of multiple
structures, that contains a flexible structure (`struct nfp_dump_tl`),
for example:

struct nfp_dumpspec_csr {
        struct nfp_dump_tl tl;

        ...

        __be32 register_width;  /* in bits */
};

So, in order to avoid ending up with flexible-array members in the
middle of multiple other structs, we use the `struct_group_tagged()`
helper to separate the flexible array from the rest of the members
in the flexible structure:

struct nfp_dump_tl {
	struct_group_tagged(nfp_dump_tl_hdr, hdr,

	... the rest of members

	);
        char data[];
};

With the change described above, we now declare objects of the type of
the tagged struct, in this case `struct nfp_dump_tl_hdr`, without
embedding flexible arrays in the middle of another struct:

struct nfp_dumpspec_csr {
        struct nfp_dump_tl_hdr tl;

	...

        __be32 register_width;  /* in bits */
};

Also, use `container_of()` whenever we need to retrieve a pointer to
the flexible structure, through which we can access the flexible
array if needed.

So, with these changes, fix 33 of the following warnings:
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:58:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:64:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:70:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:78:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:87:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:92:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/ZgYWlkxdrrieDYIu@neat
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[Ryno: backport and add compat]
Signed-off-by: Ryno Swart <ryno.swart@corigine.com>
ryno-swart-corigine pushed a commit to Corigine/nfp-drv-kmods that referenced this issue Apr 3, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

There is currently an object (`tl`), at the beginning of multiple
structures, that contains a flexible structure (`struct nfp_dump_tl`),
for example:

struct nfp_dumpspec_csr {
        struct nfp_dump_tl tl;

        ...

        __be32 register_width;  /* in bits */
};

So, in order to avoid ending up with flexible-array members in the
middle of multiple other structs, we use the `struct_group_tagged()`
helper to separate the flexible array from the rest of the members
in the flexible structure:

struct nfp_dump_tl {
	struct_group_tagged(nfp_dump_tl_hdr, hdr,

	... the rest of members

	);
        char data[];
};

With the change described above, we now declare objects of the type of
the tagged struct, in this case `struct nfp_dump_tl_hdr`, without
embedding flexible arrays in the middle of another struct:

struct nfp_dumpspec_csr {
        struct nfp_dump_tl_hdr tl;

	...

        __be32 register_width;  /* in bits */
};

Also, use `container_of()` whenever we need to retrieve a pointer to
the flexible structure, through which we can access the flexible
array if needed.

So, with these changes, fix 33 of the following warnings:
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:58:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:64:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:70:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:78:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:87:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:92:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/ZgYWlkxdrrieDYIu@neat
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[Ryno: backport and add compat]
Signed-off-by: Ryno Swart <ryno.swart@corigine.com>
1054009064 pushed a commit to 1054009064/linux that referenced this issue Apr 4, 2024
…cmd and avoid some -Wfamnae warnings

Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for an on-stack definition of
a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

So, with these changes, fix the following warning:
drivers/net/wireless/ath/wil6210/cfg80211.c:896:43: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: KSPP#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://msgid.link/ZgSP/CMSVfr68R2u@neat
1054009064 pushed a commit to 1054009064/linux that referenced this issue Apr 4, 2024
…_cmd and avoid -Wfamnae warning

Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for an on-stack definition of
a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

So, with these changes, fix the following warning:
drivers/net/wireless/ath/wil6210/wmi.c:4018:49: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: KSPP#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://msgid.link/ZgSTCmdP+omePvWg@neat
jonhunter pushed a commit to jonhunter/linux that referenced this issue Apr 5, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

There is currently an object (`hdr)` in `struct ima_max_digest_data`
that contains a flexible structure (`struct ima_digest_data`):

 struct ima_max_digest_data {
        struct ima_digest_data hdr;
        u8 digest[HASH_MAX_DIGESTSIZE];
 } __packed;

So, in order to avoid ending up with a flexible-array member in the
middle of a struct, we use the `__struct_group()` helper to separate
the flexible array from the rest of the members in the flexible
structure:

struct ima_digest_data {
        __struct_group(ima_digest_data_hdr, hdr, __packed,

        ... the rest of the members

        );
        u8 digest[];
} __packed;

And similarly for `struct evm_ima_xattr_data`.

With the change described above, we can now declare an object of the
type of the tagged `struct ima_digest_data_hdr`, without embedding the
flexible array in the middle of another struct:

 struct ima_max_digest_data {
        struct ima_digest_data_hdr hdr;
        u8 digest[HASH_MAX_DIGESTSIZE];
 } __packed;

And similarly for `struct evm_digest` and `struct evm_xattr`.

We also use `container_of()` whenever we need to retrieve a pointer to
the flexible structure.

So, with these changes, fix the following warnings:

security/integrity/evm/evm.h:64:32: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
security/integrity/evm/../integrity.h:40:35: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
security/integrity/evm/../integrity.h:68:32: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
security/integrity/ima/../integrity.h:40:35: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
security/integrity/ima/../integrity.h:68:32: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
security/integrity/integrity.h:40:35: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
security/integrity/integrity.h:68:32: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
security/integrity/platform_certs/../integrity.h:40:35: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
security/integrity/platform_certs/../integrity.h:68:32: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: KSPP#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
BluezTestBot pushed a commit to bluez/bluetooth-next that referenced this issue Apr 8, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

There are currently a couple of objects (`req` and `rsp`), in a couple
of structures, that contain flexible structures (`struct l2cap_ecred_conn_req`
and `struct l2cap_ecred_conn_rsp`), for example:

struct l2cap_ecred_rsp_data {
        struct {
                struct l2cap_ecred_conn_rsp rsp;
                __le16 scid[L2CAP_ECRED_MAX_CID];
        } __packed pdu;
        int count;
};

in the struct above, `struct l2cap_ecred_conn_rsp` is a flexible
structure:

struct l2cap_ecred_conn_rsp {
        __le16 mtu;
        __le16 mps;
        __le16 credits;
        __le16 result;
        __le16 dcid[];
};

So, in order to avoid ending up with a flexible-array member in the
middle of another structure, we use the `struct_group_tagged()` (and
`__struct_group()` when the flexible structure is `__packed`) helper
to separate the flexible array from the rest of the members in the
flexible structure:

struct l2cap_ecred_conn_rsp {
        struct_group_tagged(l2cap_ecred_conn_rsp_hdr, hdr,

	... the rest of members

        );
        __le16 dcid[];
};

With the change described above, we now declare objects of the type of
the tagged struct, in this example `struct l2cap_ecred_conn_rsp_hdr`,
without embedding flexible arrays in the middle of other structures:

struct l2cap_ecred_rsp_data {
        struct {
                struct l2cap_ecred_conn_rsp_hdr rsp;
                __le16 scid[L2CAP_ECRED_MAX_CID];
        } __packed pdu;
        int count;
};

Also, when the flexible-array member needs to be accessed, we use
`container_of()` to retrieve a pointer to the flexible structure.

We also use the `DEFINE_RAW_FLEX()` helper for a couple of on-stack
definitions of a flexible structure where the size of the flexible-array
member is known at compile-time.

So, with these changes, fix the following warnings:
net/bluetooth/l2cap_core.c:1260:45: warning: structure containing a
flexible array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:3740:45: warning: structure containing a
flexible array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:4999:45: warning: structure containing a
flexible array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:7116:47: warning: structure containing a
flexible array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
jonhunter pushed a commit to jonhunter/linux that referenced this issue Apr 9, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

There is currently an object (`hdr)` in `struct ima_max_digest_data`
that contains a flexible structure (`struct ima_digest_data`):

 struct ima_max_digest_data {
        struct ima_digest_data hdr;
        u8 digest[HASH_MAX_DIGESTSIZE];
 } __packed;

So, in order to avoid ending up with a flexible-array member in the
middle of a struct, we use the `__struct_group()` helper to separate
the flexible array from the rest of the members in the flexible
structure:

struct ima_digest_data {
        __struct_group(ima_digest_data_hdr, hdr, __packed,

        ... the rest of the members

        );
        u8 digest[];
} __packed;

And similarly for `struct evm_ima_xattr_data`.

With the change described above, we can now declare an object of the
type of the tagged `struct ima_digest_data_hdr`, without embedding the
flexible array in the middle of another struct:

 struct ima_max_digest_data {
        struct ima_digest_data_hdr hdr;
        u8 digest[HASH_MAX_DIGESTSIZE];
 } __packed;

And similarly for `struct evm_digest` and `struct evm_xattr`.

We also use `container_of()` whenever we need to retrieve a pointer to
the flexible structure.

So, with these changes, fix the following warnings:

security/integrity/evm/evm.h:64:32: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
security/integrity/evm/../integrity.h:40:35: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
security/integrity/evm/../integrity.h:68:32: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
security/integrity/ima/../integrity.h:40:35: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
security/integrity/ima/../integrity.h:68:32: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
security/integrity/integrity.h:40:35: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
security/integrity/integrity.h:68:32: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
security/integrity/platform_certs/../integrity.h:40:35: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
security/integrity/platform_certs/../integrity.h:68:32: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: KSPP#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
feiqin-corigine pushed a commit to Corigine/nfp-drv-kmods that referenced this issue Apr 9, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

There is currently an object (`tl`), at the beginning of multiple
structures, that contains a flexible structure (`struct nfp_dump_tl`),
for example:

struct nfp_dumpspec_csr {
        struct nfp_dump_tl tl;

        ...

        __be32 register_width;  /* in bits */
};

So, in order to avoid ending up with flexible-array members in the
middle of multiple other structs, we use the `struct_group_tagged()`
helper to separate the flexible array from the rest of the members
in the flexible structure:

struct nfp_dump_tl {
	struct_group_tagged(nfp_dump_tl_hdr, hdr,

	... the rest of members

	);
        char data[];
};

With the change described above, we now declare objects of the type of
the tagged struct, in this case `struct nfp_dump_tl_hdr`, without
embedding flexible arrays in the middle of another struct:

struct nfp_dumpspec_csr {
        struct nfp_dump_tl_hdr tl;

	...

        __be32 register_width;  /* in bits */
};

Also, use `container_of()` whenever we need to retrieve a pointer to
the flexible structure, through which we can access the flexible
array if needed.

So, with these changes, fix 33 of the following warnings:
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:58:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:64:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:70:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:78:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:87:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c:92:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/ZgYWlkxdrrieDYIu@neat
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[Ryno: backport and add compat]
Signed-off-by: Ryno Swart <ryno.swart@corigine.com>
Signed-off-by: Louis Peens <louis.peens@corigine.com>
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Apr 12, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

After commit 4029238 ("mei: revamp mei extension header structure layout.")
it seems that flexible-array member `data` in `struct mei_ext_hdr` is no longer
needed. So, remove it and, with that, fix 45 of the following
-Wflex-array-member-not-at-end warnings[1] in drivers/misc/mei/:

drivers/misc/mei/hw.h:280:28: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: https://gist.github.com/GustavoARSilva/62dcc235555a6b29b506269edb83da0b [1]
Link: KSPP#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/ZgHYE2s5kBGlv1cw@neat
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
smfrench pushed a commit to smfrench/smb3-kernel that referenced this issue Apr 23, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

So, in order to avoid ending up with a flexible-array member in the
middle of multiple other structs, we use the `__struct_group()` helper
to separate the flexible array from the rest of the members in the
flexible structure, and use the tagged `struct create_context_hdr`
instead of `struct create_context`.

So, with these changes, fix 51 of the following warnings[1]:

fs/smb/client/../common/smb2pdu.h:1225:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: https://gist.github.com/GustavoARSilva/772526a39be3dd4db39e71497f0a9893 [1]
Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
smfrench pushed a commit to smfrench/smb3-kernel that referenced this issue Apr 24, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

So, in order to avoid ending up with a flexible-array member in the
middle of multiple other structs, we use the `__struct_group()` helper
to separate the flexible array from the rest of the members in the
flexible structure, and use the tagged `struct create_context_hdr`
instead of `struct create_context`.

So, with these changes, fix 51 of the following warnings[1]:

fs/smb/client/../common/smb2pdu.h:1225:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: https://gist.github.com/GustavoARSilva/772526a39be3dd4db39e71497f0a9893 [1]
Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
smfrench pushed a commit to smfrench/smb3-kernel that referenced this issue Apr 24, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

So, in order to avoid ending up with a flexible-array member in the
middle of multiple other structs, we use the `__struct_group()` helper
to separate the flexible array from the rest of the members in the
flexible structure, and use the tagged `struct create_context_hdr`
instead of `struct create_context`.

So, with these changes, fix 51 of the following warnings[1]:

fs/smb/client/../common/smb2pdu.h:1225:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: https://gist.github.com/GustavoARSilva/772526a39be3dd4db39e71497f0a9893 [1]
Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
srcres258 pushed a commit to srcres258/linux-doc that referenced this issue Apr 24, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

So, in order to avoid ending up with a flexible-array member in the
middle of multiple other structs, we use the `__struct_group()` helper
to separate the flexible array from the rest of the members in the
flexible structure, and use the tagged `struct create_context_hdr`
instead of `struct create_context`.

So, with these changes, fix 51 of the following warnings[1]:

fs/smb/client/../common/smb2pdu.h:1225:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: https://gist.github.com/GustavoARSilva/772526a39be3dd4db39e71497f0a9893 [1]
Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
BluezTestBot pushed a commit to bluez/bluetooth-next that referenced this issue Apr 25, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

There are currently a couple of objects (`req` and `rsp`), in a couple
of structures, that contain flexible structures (`struct l2cap_ecred_conn_req`
and `struct l2cap_ecred_conn_rsp`), for example:

struct l2cap_ecred_rsp_data {
        struct {
                struct l2cap_ecred_conn_rsp rsp;
                __le16 scid[L2CAP_ECRED_MAX_CID];
        } __packed pdu;
        int count;
};

in the struct above, `struct l2cap_ecred_conn_rsp` is a flexible
structure:

struct l2cap_ecred_conn_rsp {
        __le16 mtu;
        __le16 mps;
        __le16 credits;
        __le16 result;
        __le16 dcid[];
};

So, in order to avoid ending up with a flexible-array member in the
middle of another structure, we use the `struct_group_tagged()` (and
`__struct_group()` when the flexible structure is `__packed`) helper
to separate the flexible array from the rest of the members in the
flexible structure:

struct l2cap_ecred_conn_rsp {
        struct_group_tagged(l2cap_ecred_conn_rsp_hdr, hdr,

	... the rest of members

        );
        __le16 dcid[];
};

With the change described above, we now declare objects of the type of
the tagged struct, in this example `struct l2cap_ecred_conn_rsp_hdr`,
without embedding flexible arrays in the middle of other structures:

struct l2cap_ecred_rsp_data {
        struct {
                struct l2cap_ecred_conn_rsp_hdr rsp;
                __le16 scid[L2CAP_ECRED_MAX_CID];
        } __packed pdu;
        int count;
};

Also, when the flexible-array member needs to be accessed, we use
`container_of()` to retrieve a pointer to the flexible structure.

We also use the `DEFINE_RAW_FLEX()` helper for a couple of on-stack
definitions of a flexible structure where the size of the flexible-array
member is known at compile-time.

So, with these changes, fix the following warnings:
net/bluetooth/l2cap_core.c:1260:45: warning: structure containing a
flexible array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:3740:45: warning: structure containing a
flexible array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:4999:45: warning: structure containing a
flexible array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:7116:47: warning: structure containing a
flexible array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
github-actions bot pushed a commit to tedd-an/bluetooth-next that referenced this issue May 10, 2024
…arnings

Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for multiple on-stack definitions
of a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

Notice that, due to the use of `__counted_by()` in `struct
hci_cp_le_create_cis`, the for loop in function `hci_cs_le_create_cis()`
had to be modified. Once the index `i`, through which `cp->cis[i]` is
accessed, falls in the interval [0, cp->num_cis), `cp->num_cis` cannot
be decremented all the way down to zero while accessing `cp->cis[]`:

net/bluetooth/hci_event.c:4310:
4310    for (i = 0; cp->num_cis; cp->num_cis--, i++) {
                ...
4314            handle = __le16_to_cpu(cp->cis[i].cis_handle);

otherwise, only half (one iteration before `cp->num_cis == i`) or half
plus one (one iteration before `cp->num_cis < i`) of the items in the
array will be accessed before running into an out-of-bounds issue. So,
in order to avoid this, set `cp->num_cis` to zero just after the for
loop.

Also, make use of `aux_num_cis` variable to update `cmd->num_cis` after
a `list_for_each_entry_rcu()` loop.

With these changes, fix the following warnings:
net/bluetooth/hci_sync.c:1239:56: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1415:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1731:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:6497:45: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
github-actions bot pushed a commit to tedd-an/bluetooth-next that referenced this issue May 10, 2024
Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for an on-stack definition of
a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

With these changes, fix the following warning:
net/bluetooth/hci_conn.c:2116:50: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
github-actions bot pushed a commit to tedd-an/bluetooth-next that referenced this issue May 10, 2024
Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for an on-stack definition of
a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

With these changes, fix the following warning:
net/bluetooth/hci_conn.c:669:41: warning: structure containing a
flexible array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
smfrench pushed a commit to smfrench/smb3-kernel that referenced this issue May 12, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

So, in order to avoid ending up with a flexible-array member in the
middle of multiple other structs, we use the `__struct_group()` helper
to separate the flexible array from the rest of the members in the
flexible structure, and use the tagged `struct create_context_hdr`
instead of `struct create_context`.

So, with these changes, fix 51 of the following warnings[1]:

fs/smb/client/../common/smb2pdu.h:1225:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: https://gist.github.com/GustavoARSilva/772526a39be3dd4db39e71497f0a9893 [1]
Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
ColinIanKing pushed a commit to ColinIanKing/linux-next that referenced this issue May 13, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

So, in order to avoid ending up with a flexible-array member in the
middle of multiple other structs, we use the `__struct_group()` helper
to separate the flexible array from the rest of the members in the
flexible structure, and use the tagged `struct create_context_hdr`
instead of `struct create_context`.

So, with these changes, fix 51 of the following warnings[1]:

fs/smb/client/../common/smb2pdu.h:1225:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: https://gist.github.com/GustavoARSilva/772526a39be3dd4db39e71497f0a9893 [1]
Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
smfrench pushed a commit to smfrench/smb3-kernel that referenced this issue May 13, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

So, in order to avoid ending up with a flexible-array member in the
middle of multiple other structs, we use the `__struct_group()` helper
to separate the flexible array from the rest of the members in the
flexible structure, and use the tagged `struct create_context_hdr`
instead of `struct create_context`.

So, with these changes, fix 51 of the following warnings[1]:

fs/smb/client/../common/smb2pdu.h:1225:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: https://gist.github.com/GustavoARSilva/772526a39be3dd4db39e71497f0a9893 [1]
Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
github-actions bot pushed a commit to BluezTestBot/bluetooth-next that referenced this issue May 14, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

There are currently a couple of objects (`req` and `rsp`), in a couple
of structures, that contain flexible structures (`struct l2cap_ecred_conn_req`
and `struct l2cap_ecred_conn_rsp`), for example:

struct l2cap_ecred_rsp_data {
        struct {
                struct l2cap_ecred_conn_rsp rsp;
                __le16 scid[L2CAP_ECRED_MAX_CID];
        } __packed pdu;
        int count;
};

in the struct above, `struct l2cap_ecred_conn_rsp` is a flexible
structure:

struct l2cap_ecred_conn_rsp {
        __le16 mtu;
        __le16 mps;
        __le16 credits;
        __le16 result;
        __le16 dcid[];
};

So, in order to avoid ending up with a flexible-array member in the
middle of another structure, we use the `struct_group_tagged()` (and
`__struct_group()` when the flexible structure is `__packed`) helper
to separate the flexible array from the rest of the members in the
flexible structure:

struct l2cap_ecred_conn_rsp {
        struct_group_tagged(l2cap_ecred_conn_rsp_hdr, hdr,

	... the rest of members

        );
        __le16 dcid[];
};

With the change described above, we now declare objects of the type of
the tagged struct, in this example `struct l2cap_ecred_conn_rsp_hdr`,
without embedding flexible arrays in the middle of other structures:

struct l2cap_ecred_rsp_data {
        struct {
                struct l2cap_ecred_conn_rsp_hdr rsp;
                __le16 scid[L2CAP_ECRED_MAX_CID];
        } __packed pdu;
        int count;
};

Also, when the flexible-array member needs to be accessed, we use
`container_of()` to retrieve a pointer to the flexible structure.

We also use the `DEFINE_RAW_FLEX()` helper for a couple of on-stack
definitions of a flexible structure where the size of the flexible-array
member is known at compile-time.

So, with these changes, fix the following warnings:
net/bluetooth/l2cap_core.c:1260:45: warning: structure containing a
flexible array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:3740:45: warning: structure containing a
flexible array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:4999:45: warning: structure containing a
flexible array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/l2cap_core.c:7116:47: warning: structure containing a
flexible array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
github-actions bot pushed a commit to BluezTestBot/bluetooth-next that referenced this issue May 14, 2024
…arnings

Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for multiple on-stack definitions
of a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

Notice that, due to the use of `__counted_by()` in `struct
hci_cp_le_create_cis`, the for loop in function `hci_cs_le_create_cis()`
had to be modified. Once the index `i`, through which `cp->cis[i]` is
accessed, falls in the interval [0, cp->num_cis), `cp->num_cis` cannot
be decremented all the way down to zero while accessing `cp->cis[]`:

net/bluetooth/hci_event.c:4310:
4310    for (i = 0; cp->num_cis; cp->num_cis--, i++) {
                ...
4314            handle = __le16_to_cpu(cp->cis[i].cis_handle);

otherwise, only half (one iteration before `cp->num_cis == i`) or half
plus one (one iteration before `cp->num_cis < i`) of the items in the
array will be accessed before running into an out-of-bounds issue. So,
in order to avoid this, set `cp->num_cis` to zero just after the for
loop.

Also, make use of `aux_num_cis` variable to update `cmd->num_cis` after
a `list_for_each_entry_rcu()` loop.

With these changes, fix the following warnings:
net/bluetooth/hci_sync.c:1239:56: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1415:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1731:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:6497:45: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
github-actions bot pushed a commit to BluezTestBot/bluetooth-next that referenced this issue May 14, 2024
Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for an on-stack definition of
a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

With these changes, fix the following warning:
net/bluetooth/hci_conn.c:2116:50: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
github-actions bot pushed a commit to BluezTestBot/bluetooth-next that referenced this issue May 14, 2024
Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for an on-stack definition of
a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

With these changes, fix the following warning:
net/bluetooth/hci_conn.c:669:41: warning: structure containing a
flexible array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
johnny-mnemonic pushed a commit to linux-ia64/linux-stable-rc that referenced this issue May 18, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

So, in order to avoid ending up with a flexible-array member in the
middle of multiple other structs, we use the `__struct_group()` helper
to separate the flexible array from the rest of the members in the
flexible structure, and use the tagged `struct create_context_hdr`
instead of `struct create_context`.

So, with these changes, fix 51 of the following warnings[1]:

fs/smb/client/../common/smb2pdu.h:1225:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: https://gist.github.com/GustavoARSilva/772526a39be3dd4db39e71497f0a9893 [1]
Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
johnny-mnemonic pushed a commit to linux-ia64/linux-stable-rc that referenced this issue May 23, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

So, in order to avoid ending up with a flexible-array member in the
middle of multiple other structs, we use the `__struct_group()` helper
to separate the flexible array from the rest of the members in the
flexible structure, and use the tagged `struct create_context_hdr`
instead of `struct create_context`.

So, with these changes, fix 51 of the following warnings[1]:

fs/smb/client/../common/smb2pdu.h:1225:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: https://gist.github.com/GustavoARSilva/772526a39be3dd4db39e71497f0a9893 [1]
Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
mj22226 pushed a commit to mj22226/linux that referenced this issue May 23, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

So, in order to avoid ending up with a flexible-array member in the
middle of multiple other structs, we use the `__struct_group()` helper
to separate the flexible array from the rest of the members in the
flexible structure, and use the tagged `struct create_context_hdr`
instead of `struct create_context`.

So, with these changes, fix 51 of the following warnings[1]:

fs/smb/client/../common/smb2pdu.h:1225:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: https://gist.github.com/GustavoARSilva/772526a39be3dd4db39e71497f0a9893 [1]
Link: KSPP#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
johnny-mnemonic pushed a commit to linux-ia64/linux-stable-rc that referenced this issue May 24, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

So, in order to avoid ending up with a flexible-array member in the
middle of multiple other structs, we use the `__struct_group()` helper
to separate the flexible array from the rest of the members in the
flexible structure, and use the tagged `struct create_context_hdr`
instead of `struct create_context`.

So, with these changes, fix 51 of the following warnings[1]:

fs/smb/client/../common/smb2pdu.h:1225:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: https://gist.github.com/GustavoARSilva/772526a39be3dd4db39e71497f0a9893 [1]
Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
gregkh pushed a commit to gregkh/linux that referenced this issue May 25, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

So, in order to avoid ending up with a flexible-array member in the
middle of multiple other structs, we use the `__struct_group()` helper
to separate the flexible array from the rest of the members in the
flexible structure, and use the tagged `struct create_context_hdr`
instead of `struct create_context`.

So, with these changes, fix 51 of the following warnings[1]:

fs/smb/client/../common/smb2pdu.h:1225:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: https://gist.github.com/GustavoARSilva/772526a39be3dd4db39e71497f0a9893 [1]
Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Avenger-285714 pushed a commit to Avenger-285714/DeepinKernel that referenced this issue May 27, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

So, in order to avoid ending up with a flexible-array member in the
middle of multiple other structs, we use the `__struct_group()` helper
to separate the flexible array from the rest of the members in the
flexible structure, and use the tagged `struct create_context_hdr`
instead of `struct create_context`.

So, with these changes, fix 51 of the following warnings[1]:

fs/smb/client/../common/smb2pdu.h:1225:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: https://gist.github.com/GustavoARSilva/772526a39be3dd4db39e71497f0a9893 [1]
Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Avenger-285714 pushed a commit to deepin-community/kernel that referenced this issue May 27, 2024
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

So, in order to avoid ending up with a flexible-array member in the
middle of multiple other structs, we use the `__struct_group()` helper
to separate the flexible array from the rest of the members in the
flexible structure, and use the tagged `struct create_context_hdr`
instead of `struct create_context`.

So, with these changes, fix 51 of the following warnings[1]:

fs/smb/client/../common/smb2pdu.h:1225:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: https://gist.github.com/GustavoARSilva/772526a39be3dd4db39e71497f0a9893 [1]
Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
johnny-mnemonic pushed a commit to linux-ia64/linux-stable-rc that referenced this issue May 27, 2024
…arnings

[ Upstream commit c4585ed ]

Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for multiple on-stack definitions
of a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

Notice that, due to the use of `__counted_by()` in `struct
hci_cp_le_create_cis`, the for loop in function `hci_cs_le_create_cis()`
had to be modified. Once the index `i`, through which `cp->cis[i]` is
accessed, falls in the interval [0, cp->num_cis), `cp->num_cis` cannot
be decremented all the way down to zero while accessing `cp->cis[]`:

net/bluetooth/hci_event.c:4310:
4310    for (i = 0; cp->num_cis; cp->num_cis--, i++) {
                ...
4314            handle = __le16_to_cpu(cp->cis[i].cis_handle);

otherwise, only half (one iteration before `cp->num_cis == i`) or half
plus one (one iteration before `cp->num_cis < i`) of the items in the
array will be accessed before running into an out-of-bounds issue. So,
in order to avoid this, set `cp->num_cis` to zero just after the for
loop.

Also, make use of `aux_num_cis` variable to update `cmd->num_cis` after
a `list_for_each_entry_rcu()` loop.

With these changes, fix the following warnings:
net/bluetooth/hci_sync.c:1239:56: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1415:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1731:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:6497:45: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Stable-dep-of: e77f43d ("Bluetooth: hci_core: Fix not handling hdev->le_num_of_adv_sets=1")
Signed-off-by: Sasha Levin <sashal@kernel.org>
johnny-mnemonic pushed a commit to linux-ia64/linux-stable-rc that referenced this issue May 27, 2024
…arnings

[ Upstream commit c4585ed ]

Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for multiple on-stack definitions
of a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

Notice that, due to the use of `__counted_by()` in `struct
hci_cp_le_create_cis`, the for loop in function `hci_cs_le_create_cis()`
had to be modified. Once the index `i`, through which `cp->cis[i]` is
accessed, falls in the interval [0, cp->num_cis), `cp->num_cis` cannot
be decremented all the way down to zero while accessing `cp->cis[]`:

net/bluetooth/hci_event.c:4310:
4310    for (i = 0; cp->num_cis; cp->num_cis--, i++) {
                ...
4314            handle = __le16_to_cpu(cp->cis[i].cis_handle);

otherwise, only half (one iteration before `cp->num_cis == i`) or half
plus one (one iteration before `cp->num_cis < i`) of the items in the
array will be accessed before running into an out-of-bounds issue. So,
in order to avoid this, set `cp->num_cis` to zero just after the for
loop.

Also, make use of `aux_num_cis` variable to update `cmd->num_cis` after
a `list_for_each_entry_rcu()` loop.

With these changes, fix the following warnings:
net/bluetooth/hci_sync.c:1239:56: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1415:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1731:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:6497:45: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Stable-dep-of: e77f43d ("Bluetooth: hci_core: Fix not handling hdev->le_num_of_adv_sets=1")
Signed-off-by: Sasha Levin <sashal@kernel.org>
johnny-mnemonic pushed a commit to linux-ia64/linux-stable-rc that referenced this issue May 27, 2024
…arnings

[ Upstream commit c4585ed ]

Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for multiple on-stack definitions
of a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

Notice that, due to the use of `__counted_by()` in `struct
hci_cp_le_create_cis`, the for loop in function `hci_cs_le_create_cis()`
had to be modified. Once the index `i`, through which `cp->cis[i]` is
accessed, falls in the interval [0, cp->num_cis), `cp->num_cis` cannot
be decremented all the way down to zero while accessing `cp->cis[]`:

net/bluetooth/hci_event.c:4310:
4310    for (i = 0; cp->num_cis; cp->num_cis--, i++) {
                ...
4314            handle = __le16_to_cpu(cp->cis[i].cis_handle);

otherwise, only half (one iteration before `cp->num_cis == i`) or half
plus one (one iteration before `cp->num_cis < i`) of the items in the
array will be accessed before running into an out-of-bounds issue. So,
in order to avoid this, set `cp->num_cis` to zero just after the for
loop.

Also, make use of `aux_num_cis` variable to update `cmd->num_cis` after
a `list_for_each_entry_rcu()` loop.

With these changes, fix the following warnings:
net/bluetooth/hci_sync.c:1239:56: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1415:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1731:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:6497:45: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Stable-dep-of: e77f43d ("Bluetooth: hci_core: Fix not handling hdev->le_num_of_adv_sets=1")
Signed-off-by: Sasha Levin <sashal@kernel.org>
johnny-mnemonic pushed a commit to linux-ia64/linux-stable-rc that referenced this issue May 27, 2024
…arnings

[ Upstream commit c4585ed ]

Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for multiple on-stack definitions
of a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

Notice that, due to the use of `__counted_by()` in `struct
hci_cp_le_create_cis`, the for loop in function `hci_cs_le_create_cis()`
had to be modified. Once the index `i`, through which `cp->cis[i]` is
accessed, falls in the interval [0, cp->num_cis), `cp->num_cis` cannot
be decremented all the way down to zero while accessing `cp->cis[]`:

net/bluetooth/hci_event.c:4310:
4310    for (i = 0; cp->num_cis; cp->num_cis--, i++) {
                ...
4314            handle = __le16_to_cpu(cp->cis[i].cis_handle);

otherwise, only half (one iteration before `cp->num_cis == i`) or half
plus one (one iteration before `cp->num_cis < i`) of the items in the
array will be accessed before running into an out-of-bounds issue. So,
in order to avoid this, set `cp->num_cis` to zero just after the for
loop.

Also, make use of `aux_num_cis` variable to update `cmd->num_cis` after
a `list_for_each_entry_rcu()` loop.

With these changes, fix the following warnings:
net/bluetooth/hci_sync.c:1239:56: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1415:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1731:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:6497:45: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Stable-dep-of: e77f43d ("Bluetooth: hci_core: Fix not handling hdev->le_num_of_adv_sets=1")
Signed-off-by: Sasha Levin <sashal@kernel.org>
johnny-mnemonic pushed a commit to linux-ia64/linux-stable-rc that referenced this issue May 28, 2024
…arnings

[ Upstream commit c4585ed ]

Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for multiple on-stack definitions
of a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

Notice that, due to the use of `__counted_by()` in `struct
hci_cp_le_create_cis`, the for loop in function `hci_cs_le_create_cis()`
had to be modified. Once the index `i`, through which `cp->cis[i]` is
accessed, falls in the interval [0, cp->num_cis), `cp->num_cis` cannot
be decremented all the way down to zero while accessing `cp->cis[]`:

net/bluetooth/hci_event.c:4310:
4310    for (i = 0; cp->num_cis; cp->num_cis--, i++) {
                ...
4314            handle = __le16_to_cpu(cp->cis[i].cis_handle);

otherwise, only half (one iteration before `cp->num_cis == i`) or half
plus one (one iteration before `cp->num_cis < i`) of the items in the
array will be accessed before running into an out-of-bounds issue. So,
in order to avoid this, set `cp->num_cis` to zero just after the for
loop.

Also, make use of `aux_num_cis` variable to update `cmd->num_cis` after
a `list_for_each_entry_rcu()` loop.

With these changes, fix the following warnings:
net/bluetooth/hci_sync.c:1239:56: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1415:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1731:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:6497:45: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Stable-dep-of: e77f43d ("Bluetooth: hci_core: Fix not handling hdev->le_num_of_adv_sets=1")
Signed-off-by: Sasha Levin <sashal@kernel.org>
johnny-mnemonic pushed a commit to linux-ia64/linux-stable-rc that referenced this issue May 28, 2024
…arnings

[ Upstream commit c4585ed ]

Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for multiple on-stack definitions
of a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

Notice that, due to the use of `__counted_by()` in `struct
hci_cp_le_create_cis`, the for loop in function `hci_cs_le_create_cis()`
had to be modified. Once the index `i`, through which `cp->cis[i]` is
accessed, falls in the interval [0, cp->num_cis), `cp->num_cis` cannot
be decremented all the way down to zero while accessing `cp->cis[]`:

net/bluetooth/hci_event.c:4310:
4310    for (i = 0; cp->num_cis; cp->num_cis--, i++) {
                ...
4314            handle = __le16_to_cpu(cp->cis[i].cis_handle);

otherwise, only half (one iteration before `cp->num_cis == i`) or half
plus one (one iteration before `cp->num_cis < i`) of the items in the
array will be accessed before running into an out-of-bounds issue. So,
in order to avoid this, set `cp->num_cis` to zero just after the for
loop.

Also, make use of `aux_num_cis` variable to update `cmd->num_cis` after
a `list_for_each_entry_rcu()` loop.

With these changes, fix the following warnings:
net/bluetooth/hci_sync.c:1239:56: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1415:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1731:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:6497:45: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Stable-dep-of: e77f43d ("Bluetooth: hci_core: Fix not handling hdev->le_num_of_adv_sets=1")
Signed-off-by: Sasha Levin <sashal@kernel.org>
johnny-mnemonic pushed a commit to linux-ia64/linux-stable-rc that referenced this issue May 28, 2024
…arnings

[ Upstream commit c4585ed ]

Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for multiple on-stack definitions
of a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

Notice that, due to the use of `__counted_by()` in `struct
hci_cp_le_create_cis`, the for loop in function `hci_cs_le_create_cis()`
had to be modified. Once the index `i`, through which `cp->cis[i]` is
accessed, falls in the interval [0, cp->num_cis), `cp->num_cis` cannot
be decremented all the way down to zero while accessing `cp->cis[]`:

net/bluetooth/hci_event.c:4310:
4310    for (i = 0; cp->num_cis; cp->num_cis--, i++) {
                ...
4314            handle = __le16_to_cpu(cp->cis[i].cis_handle);

otherwise, only half (one iteration before `cp->num_cis == i`) or half
plus one (one iteration before `cp->num_cis < i`) of the items in the
array will be accessed before running into an out-of-bounds issue. So,
in order to avoid this, set `cp->num_cis` to zero just after the for
loop.

Also, make use of `aux_num_cis` variable to update `cmd->num_cis` after
a `list_for_each_entry_rcu()` loop.

With these changes, fix the following warnings:
net/bluetooth/hci_sync.c:1239:56: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1415:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1731:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:6497:45: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Stable-dep-of: e77f43d ("Bluetooth: hci_core: Fix not handling hdev->le_num_of_adv_sets=1")
Signed-off-by: Sasha Levin <sashal@kernel.org>
johnny-mnemonic pushed a commit to linux-ia64/linux-stable-rc that referenced this issue May 28, 2024
…arnings

[ Upstream commit c4585ed ]

Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for multiple on-stack definitions
of a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

Notice that, due to the use of `__counted_by()` in `struct
hci_cp_le_create_cis`, the for loop in function `hci_cs_le_create_cis()`
had to be modified. Once the index `i`, through which `cp->cis[i]` is
accessed, falls in the interval [0, cp->num_cis), `cp->num_cis` cannot
be decremented all the way down to zero while accessing `cp->cis[]`:

net/bluetooth/hci_event.c:4310:
4310    for (i = 0; cp->num_cis; cp->num_cis--, i++) {
                ...
4314            handle = __le16_to_cpu(cp->cis[i].cis_handle);

otherwise, only half (one iteration before `cp->num_cis == i`) or half
plus one (one iteration before `cp->num_cis < i`) of the items in the
array will be accessed before running into an out-of-bounds issue. So,
in order to avoid this, set `cp->num_cis` to zero just after the for
loop.

Also, make use of `aux_num_cis` variable to update `cmd->num_cis` after
a `list_for_each_entry_rcu()` loop.

With these changes, fix the following warnings:
net/bluetooth/hci_sync.c:1239:56: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1415:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1731:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:6497:45: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Stable-dep-of: e77f43d ("Bluetooth: hci_core: Fix not handling hdev->le_num_of_adv_sets=1")
Signed-off-by: Sasha Levin <sashal@kernel.org>
gregkh pushed a commit to gregkh/linux that referenced this issue May 30, 2024
…arnings

[ Upstream commit c4585ed ]

Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for multiple on-stack definitions
of a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

Notice that, due to the use of `__counted_by()` in `struct
hci_cp_le_create_cis`, the for loop in function `hci_cs_le_create_cis()`
had to be modified. Once the index `i`, through which `cp->cis[i]` is
accessed, falls in the interval [0, cp->num_cis), `cp->num_cis` cannot
be decremented all the way down to zero while accessing `cp->cis[]`:

net/bluetooth/hci_event.c:4310:
4310    for (i = 0; cp->num_cis; cp->num_cis--, i++) {
                ...
4314            handle = __le16_to_cpu(cp->cis[i].cis_handle);

otherwise, only half (one iteration before `cp->num_cis == i`) or half
plus one (one iteration before `cp->num_cis < i`) of the items in the
array will be accessed before running into an out-of-bounds issue. So,
in order to avoid this, set `cp->num_cis` to zero just after the for
loop.

Also, make use of `aux_num_cis` variable to update `cmd->num_cis` after
a `list_for_each_entry_rcu()` loop.

With these changes, fix the following warnings:
net/bluetooth/hci_sync.c:1239:56: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1415:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1731:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:6497:45: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Stable-dep-of: e77f43d ("Bluetooth: hci_core: Fix not handling hdev->le_num_of_adv_sets=1")
Signed-off-by: Sasha Levin <sashal@kernel.org>
wanghao75 pushed a commit to openeuler-mirror/kernel that referenced this issue Jun 18, 2024
stable inclusion
from stable-v6.6.32
commit d4a079d1466d6fd9dba12a763a008b6f43890afb
bugzilla: https://gitee.com/openeuler/kernel/issues/IA4MGD

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=d4a079d1466d6fd9dba12a763a008b6f43890afb

--------------------------------

-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

So, in order to avoid ending up with a flexible-array member in the
middle of multiple other structs, we use the `__struct_group()` helper
to separate the flexible array from the rest of the members in the
flexible structure, and use the tagged `struct create_context_hdr`
instead of `struct create_context`.

So, with these changes, fix 51 of the following warnings[1]:

fs/smb/client/../common/smb2pdu.h:1225:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: https://gist.github.com/GustavoARSilva/772526a39be3dd4db39e71497f0a9893 [1]
Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
wanghao75 pushed a commit to openeuler-mirror/kernel that referenced this issue Jun 22, 2024
mainline inclusion
from mainline-v6.10-rc1
commit 140e4c85d54045ecd67f1d50fdad0fe2ecc088eb
category: feature
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I9SBWE
CVE: N/A
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=140e4c85d54045ecd67f1d50fdad0fe2ecc088eb

-------------------------------------

-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

Use the `__struct_group()` helper to separate the flexible array
from the rest of the members in flexible `struct qat_alg_buf_list`,
through tagged `struct qat_alg_buf_list_hdr`, and avoid embedding the
flexible-array member in the middle of `struct qat_alg_fixed_buf_list`.

Also, use `container_of()` whenever we need to retrieve a pointer to
the flexible structure.

So, with these changes, fix the following warnings:
drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Intel-SIG: commit 140e4c85d540 crypto: qat - Avoid -Wflex-array-member-not-at-end warnings
Backport to support QAT live migration for in-tree driver

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Acked-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <aichun.shi@intel.com>
sparkstar pushed a commit to sparkstar/noble-stable that referenced this issue Jul 1, 2024
…arnings

BugLink: https://bugs.launchpad.net/bugs/2071621

[ Upstream commit c4585edf708edb5277a3cc4b8581ccb833f3307d ]

Prepare for the coming implementation by GCC and Clang of the
__counted_by attribute. Flexible array members annotated with
__counted_by can have their accesses bounds-checked at run-time
via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE
(for strcpy/memcpy-family functions).

Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are
getting ready to enable it globally.

So, use the `DEFINE_FLEX()` helper for multiple on-stack definitions
of a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

Notice that, due to the use of `__counted_by()` in `struct
hci_cp_le_create_cis`, the for loop in function `hci_cs_le_create_cis()`
had to be modified. Once the index `i`, through which `cp->cis[i]` is
accessed, falls in the interval [0, cp->num_cis), `cp->num_cis` cannot
be decremented all the way down to zero while accessing `cp->cis[]`:

net/bluetooth/hci_event.c:4310:
4310    for (i = 0; cp->num_cis; cp->num_cis--, i++) {
                ...
4314            handle = __le16_to_cpu(cp->cis[i].cis_handle);

otherwise, only half (one iteration before `cp->num_cis == i`) or half
plus one (one iteration before `cp->num_cis < i`) of the items in the
array will be accessed before running into an out-of-bounds issue. So,
in order to avoid this, set `cp->num_cis` to zero just after the for
loop.

Also, make use of `aux_num_cis` variable to update `cmd->num_cis` after
a `list_for_each_entry_rcu()` loop.

With these changes, fix the following warnings:
net/bluetooth/hci_sync.c:1239:56: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1415:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:1731:51: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]
net/bluetooth/hci_sync.c:6497:45: warning: structure containing a flexible
array member is not at the end of another structure
[-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Stable-dep-of: e77f43d531af ("Bluetooth: hci_core: Fix not handling hdev->le_num_of_adv_sets=1")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com>
PlaidCat added a commit to ctrliq/kernel-src-tree that referenced this issue Sep 12, 2024
jira LE-1907
Rebuild_History Non-Buildable kernel-5.14.0-427.24.1.el9_4
commit-author Gustavo A. R. Silva <gustavoars@kernel.org>
commit 140e4c8

-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

Use the `__struct_group()` helper to separate the flexible array
from the rest of the members in flexible `struct qat_alg_buf_list`,
through tagged `struct qat_alg_buf_list_hdr`, and avoid embedding the
flexible-array member in the middle of `struct qat_alg_fixed_buf_list`.

Also, use `container_of()` whenever we need to retrieve a pointer to
the flexible structure.

So, with these changes, fix the following warnings:
drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Link: KSPP/linux#202
	Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
	Acked-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
	Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit 140e4c8)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants