wifi: iwlwifi: mvm: bound BA-window station ID
Subsystems (2)
cover wifi: iwlwifi: mvm: bound BA-window station ID
iwl_mvm_window_status_notif() extracts a 5-bit station ID from the firmware's BA-window status notification (values up to 31) and indexes mvm->fw_id_to_mac_id[] with it without first checking it against the firmware's station capacity. A firmware/backend notification carrying an out-of-range ID reads past the station map.
Patch 1 validates the station ID against mvm->fw->ucode_capa.num_stations before the lookup, matching the existing MVM station-lookup helpers. Patch 2 adds KUnit coverage: the malformed out-of-range ID and a valid-ID/ null-station control that must still pass.
Reproduced with the KUnit test under UBSAN bounds: the malformed case reports an array-index-out-of-bounds splat on stock and passes after the fix; the valid-ID control passes on both.
Michael Bommarito (2):
wifi: iwlwifi: mvm: check BA-window station ID before lookup
wifi: iwlwifi: mvm: add KUnit coverage for BA-window station ID bounds
drivers/net/wireless/intel/iwlwifi/mvm/rx.c | 4 + .../wireless/intel/iwlwifi/mvm/tests/Makefile | 2 +- .../intel/iwlwifi/mvm/tests/window-status.c | 77 +++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 drivers/net/wireless/intel/iwlwifi/mvm/tests/window-status.c
--
2.53.0
PATCH 1/2 wifi: iwlwifi: mvm: check BA-window station ID before lookup
iwl_mvm_window_status_notif() extracts a station ID from the BA-window status notification's ra_tid field. The firmware API allocates five bits for that field, so it can encode values up to 31.
The station map is bounded by the firmware's station capacity and physically sized to IWL_STATION_COUNT_MAX entries. Validate the extracted station ID before indexing fw_id_to_mac_id[]. This matches the existing MVM station lookup helpers, which reject IDs outside mvm->fw->ucode_capa.num_stations before reading the station map.
--- drivers/net/wireless/intel/iwlwifi/mvm/rx.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/intel/iwlwifi/mvm/rx.c +4 -0
@@ -7,6 +7,7 @@#include <linux/unaligned.h> #include <linux/etherdevice.h> #include <linux/skbuff.h> +#include "iwl-drv.h" #include "iwl-trans.h" #include "mvm.h" #include "fw-api.h"
@@ -1227,6 +1228,8 @@ void iwl_mvm_window_status_notif(struct iwl_mvm *mvm,/* get the station */ sta_id = (ratid &BA_WINDOW_STATUS_STA_ID_MSK ) >>BA_WINDOW_STATUS_STA_ID_POS ; +if (sta_id >= mvm->fw->ucode_capa.num_stations) +continue ; sta =rcu_dereference (mvm->fw_id_to_mac_id[sta_id]);if (IS_ERR_OR_NULL (sta))continue ;
@@ -1239,3 +1242,4 @@ void iwl_mvm_window_status_notif(struct iwl_mvm *mvm, }rcu_read_unlock (); } +EXPORT_SYMBOL_IF_IWLWIFI_KUNIT (iwl_mvm_window_status_notif);
Signature · 1 line
2.53.0
PATCH 2/2 wifi: iwlwifi: mvm: add KUnit coverage for BA-window station ID bounds
In reply to Michael BommaritoAdd 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.
--- .../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
drivers/net/wireless/intel/iwlwifi/mvm/tests/Makefile +1 -1
@@ -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
drivers/net/wireless/intel/iwlwifi/mvm/tests/window-status.c new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
2.53.0