From: Emmanuel Grumbach Without the SHORT_BEACON_NOTIF API, BEACON_NOTIFICATION (version 5) starts with the TX response of the beacon, followed by the TSF, the IBSS manager status and the GP2 time. The TX response is hardcoded to be struct iwl_tx_resp which assumes the new TX API. Older devices (e.g. 3160/7260) which don't use the new TX API use struct iwl_tx_resp_v3 and the driver fails to validate the size of the notification coming from the firmware. As a result, the CSA countdown never advanced and a channel switch in AP mode never completed. Compute the TX response length according to the TX API in use, and read the fields that follow it from there. Closes: https://bugzilla.kernel.org/show_bug.cgi?id=222117 Fixes: afc857bc2a71 ("iwlwifi: mvm: add notification size checks") Assisted-by: LLM Signed-off-by: Emmanuel Grumbach Reviewed-by: Johannes Berg Signed-off-by: Miri Korenblit --- drivers/net/wireless/intel/iwlwifi/fw/api/tx.h | 11 +++++++---- drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/tx.h b/drivers/net/wireless/intel/iwlwifi/fw/api/tx.h index 9d9eb320db7b..d57ec0b2ddfb 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/tx.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/tx.h @@ -845,14 +845,17 @@ struct iwl_beacon_notif { } __packed; /** - * struct iwl_extended_beacon_notif_v5 - notifies about beacon transmission - * @beacon_notify_hdr: tx response command associated with the beacon + * struct iwl_extended_beacon_notif_v5_data - beacon transmission data * @tsf: last beacon tsf * @ibss_mgr_status: whether IBSS is manager * @gp2: last beacon time in gp2 + * + * BEACON_NTFY_API_S_VER_5 starts with the TX response of the beacon and + * this follows it. The TX response is &struct iwl_tx_resp with the new TX + * API, otherwise it is &struct iwl_tx_resp_v3 with a single + * &struct agg_tx_status. */ -struct iwl_extended_beacon_notif_v5 { - struct iwl_tx_resp beacon_notify_hdr; +struct iwl_extended_beacon_notif_v5_data { __le64 tsf; __le32 ibss_mgr_status; __le32 gp2; diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c index 18372ddcc0e0..f684ec3b8a75 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c @@ -1503,13 +1503,16 @@ void iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm, lockdep_assert_held(&mvm->mutex); if (!iwl_mvm_is_short_beacon_notif_supported(mvm)) { - struct iwl_extended_beacon_notif_v5 *beacon = (void *)pkt->data; - struct iwl_tx_resp *beacon_notify_hdr = - &beacon->beacon_notify_hdr; + struct iwl_tx_resp *beacon_notify_hdr = (void *)pkt->data; + const struct iwl_extended_beacon_notif_v5_data *beacon; + size_t hdr_len = iwl_mvm_has_new_tx_api(mvm) ? + sizeof(struct iwl_tx_resp) : + struct_size_t(struct iwl_tx_resp_v3, status, 1); - if (unlikely(pkt_len < sizeof(*beacon))) + if (unlikely(pkt_len < hdr_len + sizeof(*beacon))) return; + beacon = (const void *)(pkt->data + hdr_len); beacon_gp2 = le32_to_cpu(beacon->gp2); mvm->ibss_manager = beacon->ibss_mgr_status != 0; -- 2.34.1