public inbox for linux-hardening@vger.kernel.org
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-hardening@vger.kernel.org
Subject: [PATCH][next] wifi: iwlwifi: mld: rx: Avoid a -Wflex-array-member-not-at-end warning
Date: Wed, 8 Apr 2026 14:20:46 -0600	[thread overview]
Message-ID: <ada4nkgytDjxs-Hv@kspp> (raw)

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

Use an anonymous embedded struct (enabled via -fms-extensions) to split the
header portion from the flexible-array member in struct iwl_rxq_sync_cmd,
so the new header type struct iwl_rxq_sync_cmd_hdr can be referenced
independently (of the flexible-array member), and fix the following
warning:

drivers/net/wireless/intel/iwlwifi/mld/rx.c:2172:41: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Add comments and a static_assert() to prevent adding new members
directly to struct iwl_rxq_sync_cmd. Any new members must be added
to struct iwl_rxq_sync_cmd_hdr instead. This preserves the expected
memory layout between the header and the flexible-array member.

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 .../net/wireless/intel/iwlwifi/fw/api/rx.h    | 21 ++++++++++++++++---
 drivers/net/wireless/intel/iwlwifi/mld/rx.c   |  2 +-
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
index ac6c1ef2cbcd..02a5bacfb175 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
@@ -918,19 +918,34 @@ struct iwl_rss_config_cmd {
 #define IWL_MULTI_QUEUE_SYNC_SENDER_MSK 0xf
 
 /**
- * struct iwl_rxq_sync_cmd - RXQ notification trigger
+ * struct iwl_rxq_sync_cmd_hdr - RXQ notification trigger header
  *
  * @flags: flags of the notification. bit 0:3 are the sender queue
  * @rxq_mask: rx queues to send the notification on
  * @count: number of bytes in payload, should be DWORD aligned
- * @payload: data to send to rx queues
  */
-struct iwl_rxq_sync_cmd {
+struct iwl_rxq_sync_cmd_hdr {
 	__le32 flags;
 	__le32 rxq_mask;
 	__le32 count;
+} __packed;
+
+/**
+ * struct iwl_rxq_sync_cmd - RXQ notification trigger
+ *
+ * (NOTE: New members MUST NOT be added directly to this struct. Add them to
+ * struct iwl_rxq_sync_cmd_hdr instead.)
+ *
+ * @iwl_rxq_sync_cmd_hdr: anonymous embedded header - members are directly
+ *			  accessible
+ * @payload: data to send to rx queues
+ */
+struct iwl_rxq_sync_cmd {
+	struct iwl_rxq_sync_cmd_hdr;
 	u8 payload[];
 } __packed; /* MULTI_QUEUE_DRV_SYNC_HDR_CMD_API_S_VER_1 */
+static_assert(offsetof(struct iwl_rxq_sync_cmd, payload) == sizeof(struct iwl_rxq_sync_cmd_hdr),
+	      "New members must be added to struct iwl_rxq_sync_cmd_hdr instead.");
 
 /**
  * struct iwl_rxq_sync_notification - Notification triggered by RXQ
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/rx.c b/drivers/net/wireless/intel/iwlwifi/mld/rx.c
index a2e586c6ea67..492c03b8e5a0 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/rx.c
@@ -2172,7 +2172,7 @@ void iwl_mld_sync_rx_queues(struct iwl_mld *mld,
 {
 	u8 num_rx_queues = mld->trans->info.num_rxqs;
 	struct {
-		struct iwl_rxq_sync_cmd sync_cmd;
+		struct iwl_rxq_sync_cmd_hdr sync_cmd;
 		struct iwl_mld_internal_rxq_notif notif;
 	} __packed cmd = {
 		.sync_cmd.rxq_mask = cpu_to_le32(BIT(num_rx_queues) - 1),
-- 
2.43.0


                 reply	other threads:[~2026-04-08 20:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ada4nkgytDjxs-Hv@kspp \
    --to=gustavoars@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=miriam.rachel.korenblit@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox