Linux wireless drivers development
 help / color / mirror / Atom feed
From: Maoyi Xie <maoyixie.tju@gmail.com>
To: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH iwlwifi-next 4/4] wifi: iwlwifi: pcie: validate txq_id in reclaim
Date: Wed, 25 Nov 2026 16:37:42 +0800	[thread overview]
Message-ID: <20261125083742.1355074-5-maoyixie.tju@gmail.com> (raw)
In-Reply-To: <20261125083742.1355074-1-maoyixie.tju@gmail.com>

iwl_pcie_reclaim() indexes trans_pcie->txqs.txq[] with a 16-bit queue
number that mvm takes unchecked from TX responses, BA notifications
and flush responses. A queue number of 512 or more reads past the
array.

Add a range check against num_of_queues with IWL_FW_CHECK() before the
access.

Found with a CodeQL-based static analysis tool.
Reproduced with a TX response in a userspace harness under
AddressSanitizer and UBSan. Not tested on hardware.

Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>
---
I used an LLM to help write the harness and this patch.

 drivers/net/wireless/intel/iwlwifi/pcie/tx.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
index 0c29fb6b9ca7..48165a40e2cc 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
@@ -2364,14 +2364,21 @@ void iwl_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
 		      struct sk_buff_head *skbs, bool is_flush)
 {
 	struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
-	struct iwl_txq *txq = trans_pcie->txqs.txq[txq_id];
+	struct iwl_txq *txq;
 	int tfd_num, read_ptr, last_to_free;
 	int txq_read_ptr, txq_write_ptr;
 
+	if (IWL_FW_CHECK(trans,
+			 txq_id < 0 ||
+			 txq_id >= trans->mac_cfg->base->num_of_queues,
+			 "queue %d out of range\n", txq_id))
+		return;
+
 	/* This function is not meant to release cmd queue*/
 	if (WARN_ON(txq_id == trans->conf.cmd_queue))
 		return;
 
+	txq = trans_pcie->txqs.txq[txq_id];
 	if (WARN_ON(!txq))
 		return;
 
-- 
2.34.1


      parent reply	other threads:[~2026-11-25  8:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  8:37 [PATCH iwlwifi-next 0/4] wifi: iwlwifi: validate more indices from the firmware Maoyi Xie
2026-11-25  8:37 ` [PATCH iwlwifi-next 1/4] wifi: iwlwifi: mvm: validate TID in TX response handlers Maoyi Xie
2026-11-25  8:37 ` [PATCH iwlwifi-next 2/4] wifi: iwlwifi: mvm: validate BAID in the RX path Maoyi Xie
2026-11-25  8:37 ` [PATCH iwlwifi-next 3/4] wifi: iwlwifi: mld: validate BAID in the RX timestamp update Maoyi Xie
2026-11-25  8:37 ` Maoyi Xie [this message]

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=20261125083742.1355074-5-maoyixie.tju@gmail.com \
    --to=maoyixie.tju@gmail.com \
    --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