Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: "David Härdeman" <david@hardeman.nu>
To: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Cc: "Emmanuel Grumbach" <emmanuel.grumbach@intel.com>,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	"David Härdeman" <david@hardeman.nu>,
	stable@vger.kernel.org
Subject: [PATCH 2/2] wifi: iwlwifi: mld: release frames before one beyond the window
Date: Mon, 16 Nov 2026 16:56:09 +0100	[thread overview]
Message-ID: <20261116155609.535595-3-david@hardeman.nu> (raw)
In-Reply-To: <20261116155609.535595-1-david@hardeman.nu>

iwl_mld_reorder() has the same problem as iwlmvm had: a frame with
SN >= head_sn + buf_size, which a transmitter sends after giving up on
an older MPDU without a BAR, is stored in the slot of head_sn, and
iwl_mld_reorder_release_frames() then passes it to mac80211 ahead of
the frames before it, which all fail the PN check.

Release the older frames first, up to min(sn, nssn), as iwlmvm did
before the reorder buffer was simplified, and add a KUnit case for it.

Not tested on hardware (seen and tested with iwlmvm on an AX210); the
new KUnit case fails without the fix (SN=164 is released first) and
passes with it.

Fixes: d1e879ec600f ("wifi: iwlwifi: add iwlmld sub-driver")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: David Härdeman <david@hardeman.nu>
---
 drivers/net/wireless/intel/iwlwifi/mld/agg.c  | 14 ++++++++++
 .../wireless/intel/iwlwifi/mld/tests/agg.c    | 28 +++++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mld/agg.c b/drivers/net/wireless/intel/iwlwifi/mld/agg.c
index ea1f02380ad..6b3c311a3d3 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/agg.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/agg.c
@@ -305,6 +305,20 @@ iwl_mld_reorder(struct iwl_mld *mld, struct napi_struct *napi,
 		return IWL_MLD_PASS_SKB;
 	}
 
+	/* A frame beyond the end of the reorder window means that the
+	 * transmitter gave up on older frames without sending a BAR. The
+	 * firmware moves the window (NSSN) for it, but the frame would be
+	 * stored in the slot of an older SN and released ahead of the frames
+	 * before it, which would then all fail the PN check. Release the
+	 * older frames first, as for a BAR.
+	 */
+	if (!ieee80211_sn_less(sn, ieee80211_sn_add(buffer->head_sn,
+						    baid_data->buf_size)))
+		iwl_mld_reorder_release_frames(mld, link_sta, napi, baid_data,
+					       buffer,
+					       ieee80211_sn_less(sn, nssn) ?
+					       sn : nssn);
+
 	/* put in reorder buffer */
 	index = sn % baid_data->buf_size;
 	__skb_queue_tail(&entries[index].frames, skb);
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/tests/agg.c b/drivers/net/wireless/intel/iwlwifi/mld/tests/agg.c
index e9efe2996f0..8fec274cc25 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/tests/agg.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/tests/agg.c
@@ -426,6 +426,34 @@ static const struct reorder_buffer_case {
 			.head_sn = 100,
 		},
 	},
+	{
+		.desc = "RX packet beyond the reorder window, release older packets first",
+		.rx_pkt = {
+			.fc = FC_QOS_DATA,
+			.sn = 164,
+			.nssn = 165,
+		},
+		.reorder_buf_state = {
+			.valid = true,
+			.head_sn = 100,
+			.num_entries = 2,
+			.entries[0].sn = 101,
+			.entries[1].sn = 102,
+		},
+		.expected = {
+			/* 1. Reorder buffer contains SN={101, 102}, hole at 100.
+			 * 2. RX packet SN=164 = head_sn + BA_WINDOW_SIZE: the
+			 *    transmitter gave up on SN=100 (no BAR), NSSN moves
+			 *    past it. SN=164 maps to the slot of SN=100.
+			 * The stored packets are released before the RX packet.
+			 */
+			.reorder_res = IWL_MLD_BUFFERED_SKB,
+			.num_stored = 0,
+			.head_sn = 165,
+			.skb_release_order = {101, 102, 164},
+			.skb_release_order_count = 3,
+		},
+	},
 };
 
 KUNIT_ARRAY_PARAM_DESC(test_reorder_buffer, reorder_buffer_cases, desc);
-- 
2.47.3


      parent reply	other threads:[~2026-11-16 15:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261116155609.535595-1-david@hardeman.nu>
2026-11-16 15:56 ` [PATCH 1/2] wifi: iwlwifi: mvm: release frames before one beyond the window David Härdeman
2026-11-16 15:56 ` David Härdeman [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=20261116155609.535595-3-david@hardeman.nu \
    --to=david@hardeman.nu \
    --cc=emmanuel.grumbach@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=miriam.rachel.korenblit@intel.com \
    --cc=stable@vger.kernel.org \
    /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