From: Michael Bommarito <michael.bommarito@gmail.com>
To: Miri Korenblit <miriam.rachel.korenblit@intel.com>,
Johannes Berg <johannes.berg@intel.com>
Cc: Emmanuel Grumbach <emmanuel.grumbach@intel.com>,
Benjamin Berg <benjamin.berg@intel.com>,
linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: [PATCH 2/2] wifi: iwlwifi: mvm: add KUnit coverage for BA-window station ID bounds
Date: Sat, 11 Jul 2026 11:06:11 -0400 [thread overview]
Message-ID: <20260711150611.2913332-3-michael.bommarito@gmail.com> (raw)
In-Reply-To: <20260711150611.2913332-1-michael.bommarito@gmail.com>
Add KUnit coverage for a malformed BA-window notification carrying an
out-of-range station ID, plus a valid-ID/null-station path to exercise the
adjacent non-bug branch. With UBSAN bounds enabled, the malformed case
reports an array-index-out-of-bounds splat before the fix and passes after
it.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
---
.../wireless/intel/iwlwifi/mvm/tests/Makefile | 2 +-
.../intel/iwlwifi/mvm/tests/window-status.c | 77 +++++++++++++++++++
2 files changed, 78 insertions(+), 1 deletion(-)
create mode 100644 drivers/net/wireless/intel/iwlwifi/mvm/tests/window-status.c
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tests/Makefile b/drivers/net/wireless/intel/iwlwifi/mvm/tests/Makefile
index 2267be4cfb441..bf22750fceafc 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tests/Makefile
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tests/Makefile
@@ -1,3 +1,3 @@
-iwlmvm-tests-y += module.o hcmd.o
+iwlmvm-tests-y += module.o hcmd.o window-status.o
obj-$(CONFIG_IWLWIFI_KUNIT_TESTS) += iwlmvm-tests.o
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tests/window-status.c b/drivers/net/wireless/intel/iwlwifi/mvm/tests/window-status.c
new file mode 100644
index 0000000000000..06807e2bdbc12
--- /dev/null
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tests/window-status.c
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+/*
+ * KUnit tests for MVM BA window status notification handling
+ */
+#include <kunit/test.h>
+#include <linux/mm.h>
+
+#include <iwl-trans.h>
+#include "../fw-api.h"
+#include "../mvm.h"
+
+MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
+
+static void iwl_mvm_test_window_status(struct kunit *test, u8 sta_id)
+{
+ struct iwl_ba_window_status_notif notif = {};
+ struct iwl_rx_cmd_buffer rxb = {
+ ._offset = 0,
+ ._rx_page_order = 0,
+ };
+ struct iwl_rx_packet *pkt;
+ struct iwl_fw *fw;
+ struct iwl_mvm *mvm;
+ u16 ratid;
+
+ BUILD_BUG_ON((IWL_STATION_COUNT_MAX + 1) >
+ (BA_WINDOW_STATUS_STA_ID_MSK >>
+ BA_WINDOW_STATUS_STA_ID_POS));
+
+ mvm = kunit_kzalloc(test, sizeof(*mvm), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, mvm);
+
+ fw = kunit_kzalloc(test, sizeof(*fw), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, fw);
+ fw->ucode_capa.num_stations = IWL_STATION_COUNT_MAX;
+ mvm->fw = fw;
+
+ rxb._page = alloc_page(GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, rxb._page);
+
+ ratid = BA_WINDOW_STATUS_VALID_MSK |
+ (sta_id << BA_WINDOW_STATUS_STA_ID_POS);
+ notif.ra_tid[0] = cpu_to_le16(ratid);
+ notif.mpdu_rx_count[0] = cpu_to_le16(1);
+
+ pkt = rxb_addr(&rxb);
+ memset(pkt, 0, PAGE_SIZE);
+ pkt->len_n_flags = cpu_to_le32(sizeof(pkt->hdr) + sizeof(notif));
+ memcpy(pkt->data, ¬if, sizeof(notif));
+
+ iwl_mvm_window_status_notif(mvm, &rxb);
+
+ __free_page(rxb._page);
+}
+
+static void test_ba_window_status_station_id_bounds(struct kunit *test)
+{
+ iwl_mvm_test_window_status(test, IWL_STATION_COUNT_MAX + 1);
+}
+
+static void test_ba_window_status_valid_empty_station(struct kunit *test)
+{
+ iwl_mvm_test_window_status(test, 0);
+}
+
+static struct kunit_case window_status_cases[] = {
+ KUNIT_CASE(test_ba_window_status_station_id_bounds),
+ KUNIT_CASE(test_ba_window_status_valid_empty_station),
+ {},
+};
+
+static struct kunit_suite window_status = {
+ .name = "iwlmvm-window-status",
+ .test_cases = window_status_cases,
+};
+
+kunit_test_suite(window_status);
--
2.53.0
prev parent reply other threads:[~2026-07-11 15:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 15:06 [PATCH 0/2] wifi: iwlwifi: mvm: bound BA-window station ID Michael Bommarito
2026-07-11 15:06 ` [PATCH 1/2] wifi: iwlwifi: mvm: check BA-window station ID before lookup Michael Bommarito
2026-07-11 15:06 ` Michael Bommarito [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=20260711150611.2913332-3-michael.bommarito@gmail.com \
--to=michael.bommarito@gmail.com \
--cc=benjamin.berg@intel.com \
--cc=emmanuel.grumbach@intel.com \
--cc=johannes.berg@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