wifi: iwlwifi: fixes for v6.4 2023-05-14
cover wifi: iwlwifi: fixes for v6.4 2023-05-14
From: Gregory Greenman <[email protected]>
Hi,
Here're a few iwlwifi fixes that we'd like to send to v6.4. Fixing a few locking and memory issues, MLO fix and a few other rather small fixes.
Thanks,
Gregory
Alon Giladi (2):
wifi: iwlwifi: fix OEM's name in the ppag approved list
wifi: iwlwifi: mvm: fix OEM's name in the tas approved list
Ariel Malamud (1):
wifi: iwlwifi: mvm: Add locking to the rate read flow
Gregory Greenman (1):
wifi: iwlwifi: mvm: fix access to fw_id_to_mac_id
Johannes Berg (6):
wifi: iwlwifi: mvm: always free dup_data
wifi: iwlwifi: mvm: don't double-init spinlock
wifi: iwlwifi: mvm: fix cancel_delayed_work_sync() deadlock
wifi: iwlwifi: mvm: fix number of concurrent link checks
wifi: iwlwifi: fw: fix DBGI dump
wifi: iwlwifi: mvm: don't trust firmware n_channels
Miri Korenblit (1):
wifi: iwlwifi: Don't use valid_links to iterate sta links
Mukesh Sisodiya (1):
wifi: iwlwifi: mvm: fix initialization of a return value
drivers/net/wireless/intel/iwlwifi/fw/acpi.c | 2 +- drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 19 ++++--- .../intel/iwlwifi/mvm/ftm-initiator.c | 5 ++ drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 2 +- drivers/net/wireless/intel/iwlwifi/mvm/link.c | 12 ++-- .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 55 +++++++++---------- .../wireless/intel/iwlwifi/mvm/mld-mac80211.c | 9 +-- .../net/wireless/intel/iwlwifi/mvm/mld-sta.c | 14 ++--- drivers/net/wireless/intel/iwlwifi/mvm/nvm.c | 10 ++++ drivers/net/wireless/intel/iwlwifi/mvm/rs.c | 3 + drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 9 ++- drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 13 +++-- drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 2 +- 13 files changed, 92 insertions(+), 63 deletions(-)
Signature · 1 line
2.38.1
PATCH 1/12 wifi: iwlwifi: mvm: always free dup_data
From: Johannes Berg <[email protected]>
There are some assertions in the STA removal code that can fail, and in that case we may leak memory since we skip the freeing.
Fix this by freeing the dup_data earlier in the function, we already have a check for when we free the station, and this we don't need to do it with and without MLD API, so it's a win all around.
--- drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 3 +++ drivers/net/wireless/intel/iwlwifi/mvm/mld-sta.c | 2 -- drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 3 --- 3 files changed, 3 insertions(+), 5 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +3 -0
@@ -3889,6 +3889,9 @@ int iwl_mvm_mac_sta_state_common(struct ieee80211_hw *hw,* from the AP now. */ iwl_mvm_reset_cca_40mhz_workaround (mvm, vif); + +/* Also free dup data just in case any assertions below fail */ +kfree (mvm_sta->dup_data); }mutex_lock (&mvm->mutex);
drivers/net/wireless/intel/iwlwifi/mvm/mld-sta.c +0 -2
@@ -791,8 +791,6 @@ int iwl_mvm_mld_rm_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif,lockdep_assert_held (&mvm->mutex); -kfree (mvm_sta->dup_data); -/* flush its queues here since we are freeing mvm_sta */ for_each_sta_active_link (vif, sta, link_sta, link_id) { struct iwl_mvm_link_sta *mvm_link_sta =
drivers/net/wireless/intel/iwlwifi/mvm/sta.c +0 -3
@@ -2089,9 +2089,6 @@ int iwl_mvm_rm_sta(struct iwl_mvm *mvm,lockdep_assert_held (&mvm->mutex); -if (iwl_mvm_has_new_rx_api (mvm)) -kfree (mvm_sta->dup_data); - ret =iwl_mvm_drain_sta (mvm, mvm_sta, true);if (ret)return ret;
Signature · 1 line
2.38.1
PATCH 2/12 wifi: iwlwifi: mvm: don't double-init spinlock
In reply to [email protected]From: Johannes Berg <[email protected]>
We don't need to (and shouldn't) initialize the spinlock during HW restart that was already initialized, so move that into the correct if block. Since then we have two consecutive if statements with the same (though inverted) condition, unify those as well.
--- drivers/net/wireless/intel/iwlwifi/mvm/mld-sta.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/mld-sta.c +5 -5
@@ -667,15 +667,15 @@ int iwl_mvm_mld_add_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif, ret =iwl_mvm_mld_alloc_sta_links (mvm, vif, sta);if (ret)return ret; - } -spin_lock_init (&mvm_sta->lock); +spin_lock_init (&mvm_sta->lock); -if (test_bit (IWL_MVM_STATUS_IN_HW_RESTART , &mvm->status)) - ret =iwl_mvm_alloc_sta_after_restart (mvm, vif, sta); -else ret =iwl_mvm_sta_init (mvm, vif, sta,IWL_MVM_INVALID_STA ,STATION_TYPE_PEER ); + }else { + ret =iwl_mvm_alloc_sta_after_restart (mvm, vif, sta); + } +if (ret) goto err;
Signature · 1 line
2.38.1
PATCH 3/12 wifi: iwlwifi: mvm: fix cancel_delayed_work_sync() deadlock
In reply to [email protected]From: Johannes Berg <[email protected]>
Lockdep points out that we can deadlock here by calling cancel_delayed_work_sync() because that might be already running and gotten interrupted by the NAPI soft-IRQ. Even just calling something that can sleep is wrong in this context though.
Luckily, it doesn't even really matter since the things we need to do are idempotent, so just drop the _sync().
--- drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +1 -1
@@ -2512,7 +2512,7 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,RCU_INIT_POINTER (mvm->csa_tx_blocked_vif,NULL );/* Unblock BCAST / MCAST station */ iwl_mvm_modify_all_sta_disable_tx (mvm, mvmvif, false); -cancel_delayed_work_sync (&mvm->cs_tx_unblock_dwork); +cancel_delayed_work (&mvm->cs_tx_unblock_dwork); } }
Signature · 1 line
2.38.1
PATCH 4/12 wifi: iwlwifi: mvm: fix number of concurrent link checks
In reply to [email protected]From: Johannes Berg <[email protected]>
The concurrent link checks need to correctly differentiate between AP and non-AP, fix that.
--- drivers/net/wireless/intel/iwlwifi/mvm/link.c | 12 +++++++----- .../net/wireless/intel/iwlwifi/mvm/mld-mac80211.c | 9 +++++---- 2 files changed, 12 insertions(+), 9 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/link.c +7 -5
@@ -123,11 +123,13 @@ int iwl_mvm_link_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,if (mvmvif->link[i]->phy_ctxt) count++; -/* FIXME: IWL_MVM_FW_MAX_ACTIVE_LINKS_NUM should be -* defined per HW -*/ -if (count >=IWL_MVM_FW_MAX_ACTIVE_LINKS_NUM ) -return -EINVAL ; +if (vif->type ==NL80211_IFTYPE_AP ) { +if (count > mvm->fw->ucode_capa.num_beacons) +return -EOPNOTSUPP ; +/* this should be per HW or such */ + }else if (count >=IWL_MVM_FW_MAX_ACTIVE_LINKS_NUM ) { +return -EOPNOTSUPP ; + } }/* Catch early if driver tries to activate or deactivate a link
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c +5 -4
@@ -906,11 +906,12 @@ iwl_mvm_mld_change_vif_links(struct ieee80211_hw *hw, n_active++; } -if (vif->type ==NL80211_IFTYPE_AP && - n_active > mvm->fw->ucode_capa.num_beacons) -return -EOPNOTSUPP ; -else if (n_active >1 ) +if (vif->type ==NL80211_IFTYPE_AP ) { +if (n_active > mvm->fw->ucode_capa.num_beacons) +return -EOPNOTSUPP ; + }else if (n_active >1 ) {return -EOPNOTSUPP ; + } }for (i =0 ; i <IEEE80211_MLD_MAX_NUM_LINKS ; i++) {
Signature · 1 line
2.38.1
PATCH 5/12 wifi: iwlwifi: fw: fix DBGI dump
In reply to [email protected]From: Johannes Berg <[email protected]>
The DBGI dump is (unsurprisingly) of type DBGI, not SRAM. This leads to bad register accesses because the union is built differently, there's no allocation ID, and thus the allocation ID ends up being 0x8000.
Note that this was already wrong for DRAM vs. SMEM since they use different parts of the union, but the allocation ID is at the same place, so it worked.
Fix all of this but set the allocation ID in a way that the offset calculation ends up without any offset.
--- drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/dbg.c +11 -8
@@ -1664,14 +1664,10 @@ static __le32 iwl_get_mon_reg(struct iwl_fw_runtime *fwrt, u32 alloc_id, }static void * -iwl_dump_ini_mon_fill_header (struct iwl_fw_runtime *fwrt, -struct iwl_dump_ini_region_data *reg_data, +iwl_dump_ini_mon_fill_header (struct iwl_fw_runtime *fwrt,u32 alloc_id,struct iwl_fw_ini_monitor_dump *data,const struct iwl_fw_mon_regs *addrs) { -struct iwl_fw_ini_region_tlv *reg = (void *)reg_data->reg_tlv->data; -u32 alloc_id =le32_to_cpu (reg->dram_alloc_id); -if (!iwl_trans_grab_nic_access (fwrt->trans)) {IWL_ERR (fwrt,"Failed to get monitor header\n" );return NULL ;
@@ -1702,8 +1698,10 @@ iwl_dump_ini_mon_dram_fill_header(struct iwl_fw_runtime *fwrt, void *data, u32 data_len) {struct iwl_fw_ini_monitor_dump *mon_dump = (void *)data; +struct iwl_fw_ini_region_tlv *reg = (void *)reg_data->reg_tlv->data; +u32 alloc_id =le32_to_cpu (reg->dram_alloc_id); -return iwl_dump_ini_mon_fill_header (fwrt, reg_data, mon_dump, +return iwl_dump_ini_mon_fill_header (fwrt, alloc_id, mon_dump, &fwrt->trans->cfg->mon_dram_regs); }
@@ -1713,8 +1711,10 @@ iwl_dump_ini_mon_smem_fill_header(struct iwl_fw_runtime *fwrt, void *data, u32 data_len) {struct iwl_fw_ini_monitor_dump *mon_dump = (void *)data; +struct iwl_fw_ini_region_tlv *reg = (void *)reg_data->reg_tlv->data; +u32 alloc_id =le32_to_cpu (reg->internal_buffer.alloc_id); -return iwl_dump_ini_mon_fill_header (fwrt, reg_data, mon_dump, +return iwl_dump_ini_mon_fill_header (fwrt, alloc_id, mon_dump, &fwrt->trans->cfg->mon_smem_regs); }
@@ -1725,7 +1725,10 @@ iwl_dump_ini_mon_dbgi_fill_header(struct iwl_fw_runtime *fwrt, {struct iwl_fw_ini_monitor_dump *mon_dump = (void *)data; -return iwl_dump_ini_mon_fill_header (fwrt, reg_data, mon_dump, +return iwl_dump_ini_mon_fill_header (fwrt, +/* no offset calculation later */ +IWL_FW_INI_ALLOCATION_ID_DBGC1 , + mon_dump, &fwrt->trans->cfg->mon_dbgi_regs); }
Signature · 1 line
2.38.1
PATCH 6/12 wifi: iwlwifi: mvm: fix access to fw_id_to_mac_id
In reply to [email protected]From: Gregory Greenman <[email protected]>
RCU protected fw_id_to_mac_id can be initialized with either an error code or NULL. Thus, after dereferencing need to check the value with IS_ERR_OR_NULL() and not only that it is not NULL. Fix it.
--- drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c | 5 +++++ drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 7 +++++++ drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 10 +++++++++- drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 2 +- 4 files changed, 22 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c +5 -0
@@ -526,6 +526,11 @@ iwl_mvm_ftm_put_target(struct iwl_mvm *mvm, struct ieee80211_vif *vif,rcu_read_lock (); sta =rcu_dereference (mvm->fw_id_to_mac_id[mvmvif->deflink.ap_sta_id]); +if (WARN_ON_ONCE (IS_ERR_OR_NULL (sta))) { +rcu_read_unlock (); +return PTR_ERR_OR_ZERO (sta); + } +if (sta->mfp && (peer->ftm.trigger_based || peer->ftm.non_trigger_based))FTM_PUT_FLAG (PMF );
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +7 -0
@@ -691,6 +691,11 @@ void iwl_mvm_reorder_timer_expired(struct timer_list *t)rcu_read_lock (); sta =rcu_dereference (buf->mvm->fw_id_to_mac_id[sta_id]); +if (WARN_ON_ONCE (IS_ERR_OR_NULL (sta))) { +rcu_read_unlock (); + goto out; + } + mvmsta =iwl_mvm_sta_from_mac80211 (sta);/* SN is set to the last expired frame + 1 */
@@ -712,6 +717,8 @@ void iwl_mvm_reorder_timer_expired(struct timer_list *t) entries[index].e.reorder_time + 1 + RX_REORDER_BUF_TIMEOUT_MQ); } + +out:spin_unlock (&buf->lock); }
drivers/net/wireless/intel/iwlwifi/mvm/sta.c +9 -1
@@ -281,7 +281,7 @@ static void iwl_mvm_rx_agg_session_expired(struct timer_list *t)* A-MDPU and hence the timer continues to run. Then, the * timer expires and sta is NULL. */ -if (!sta) +if (IS_ERR_OR_NULL (sta)) goto unlock; mvm_sta =iwl_mvm_sta_from_mac80211 (sta);
@@ -3782,6 +3782,9 @@ static inline u8 *iwl_mvm_get_mac_addr(struct iwl_mvm *mvm,u8 sta_id = mvmvif->deflink.ap_sta_id; sta =rcu_dereference_protected (mvm->fw_id_to_mac_id[sta_id],lockdep_is_held (&mvm->mutex)); +if (WARN_ON_ONCE (IS_ERR_OR_NULL (sta))) +return NULL ; +return sta->addr; }
@@ -3819,6 +3822,11 @@ static int __iwl_mvm_set_sta_key(struct iwl_mvm *mvm,if (keyconf->cipher ==WLAN_CIPHER_SUITE_TKIP ) { addr =iwl_mvm_get_mac_addr (mvm, vif, sta); +if (!addr) { +IWL_ERR (mvm,"Failed to find mac address\n" ); +return -EINVAL ; + } +/* get phase 1 key from mac80211 */ ieee80211_get_key_rx_seq (keyconf,0 , &seq);ieee80211_get_tkip_rx_p1k (keyconf, addr, seq.tkip.iv32, p1k);
drivers/net/wireless/intel/iwlwifi/mvm/tx.c +1 -1
@@ -1875,7 +1875,7 @@ static void iwl_mvm_rx_tx_cmd_agg(struct iwl_mvm *mvm, mvmsta =iwl_mvm_sta_from_staid_rcu (mvm, sta_id); sta =rcu_dereference (mvm->fw_id_to_mac_id[sta_id]); -if (WARN_ON_ONCE (!sta || !sta->wme)) { +if (WARN_ON_ONCE (IS_ERR_OR_NULL (sta) || !sta->wme)) {rcu_read_unlock ();return ; }
Signature · 1 line
2.38.1
PATCH 7/12 wifi: iwlwifi: mvm: fix initialization of a return value
In reply to [email protected]From: Mukesh Sisodiya <[email protected]>
In iwl_mvm_mld_update_sta(), if the flow doesn't enter for_each_sta_active_link(), the default value is returned. Set this default to -EINVAL instead of 0 to better reflect this.
--- drivers/net/wireless/intel/iwlwifi/mvm/mld-sta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/mld-sta.c +1 -1
@@ -728,7 +728,7 @@ int iwl_mvm_mld_update_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif,struct iwl_mvm_sta *mvm_sta =iwl_mvm_sta_from_mac80211 (sta);struct ieee80211_link_sta *link_sta;unsigned int link_id; -int ret =0 ; +int ret = -EINVAL ;lockdep_assert_held (&mvm->mutex);
Signature · 1 line
2.38.1
PATCH 8/12 wifi: iwlwifi: fix OEM's name in the ppag approved list
In reply to [email protected]From: Alon Giladi <[email protected]>
Fix a spelling mistake.
--- drivers/net/wireless/intel/iwlwifi/fw/acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/fw/acpi.c +1 -1
@@ -38,7 +38,7 @@ static const struct dmi_system_id dmi_ppag_approved_list[] = { }, { .ident = "ASUS", .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTek COMPUTER INC."), + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), }, }, {}
Signature · 1 line
2.38.1
PATCH 9/12 wifi: iwlwifi: mvm: fix OEM's name in the tas approved list
In reply to [email protected]From: Alon Giladi <[email protected]>
Fix a spelling mistake.
--- drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/fw.c +1 -1
@@ -1091,7 +1091,7 @@ static const struct dmi_system_id dmi_tas_approved_list[] = { }, { .ident = "LENOVO", .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Lenovo" ), +DMI_MATCH (DMI_SYS_VENDOR ,"LENOVO" ), }, }, { .ident = "DELL",
Signature · 1 line
2.38.1
PATCH 10/12 wifi: iwlwifi: mvm: don't trust firmware n_channels
In reply to [email protected]From: Johannes Berg <[email protected]>
If the firmware sends us a corrupted MCC response with n_channels much larger than the command response can be, we might copy far too much (uninitialized) memory and even crash if the n_channels is large enough to make it run out of the one page allocated for the FW response.
Fix that by checking the lengths. Doing a < comparison would be sufficient, but the firmware should be doing it correctly, so check more strictly.
--- drivers/net/wireless/intel/iwlwifi/mvm/nvm.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/wireless/intel/iwlwifi/mvm/nvm.c +10 -0
@@ -445,6 +445,11 @@ iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2,struct iwl_mcc_update_resp *mcc_resp = (void *)pkt->data; n_channels =__le32_to_cpu (mcc_resp->n_channels); +if (iwl_rx_packet_payload_len (pkt) != +struct_size (mcc_resp, channels, n_channels)) { + resp_cp =ERR_PTR (-EINVAL ); + goto exit; + } resp_len =sizeof (struct iwl_mcc_update_resp ) + n_channels *sizeof (__le32); resp_cp =kmemdup (mcc_resp, resp_len,GFP_KERNEL );
@@ -456,6 +461,11 @@ iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2,struct iwl_mcc_update_resp_v3 *mcc_resp_v3 = (void *)pkt->data; n_channels =__le32_to_cpu (mcc_resp_v3->n_channels); +if (iwl_rx_packet_payload_len (pkt) != +struct_size (mcc_resp_v3, channels, n_channels)) { + resp_cp =ERR_PTR (-EINVAL ); + goto exit; + } resp_len =sizeof (struct iwl_mcc_update_resp ) + n_channels *sizeof (__le32); resp_cp =kzalloc (resp_len,GFP_KERNEL );
Signature · 1 line
2.38.1
PATCH 11/12 wifi: iwlwifi: Don't use valid_links to iterate sta links
In reply to [email protected]From: Miri Korenblit <[email protected]>
This bitmap equals to zero when in a non-MLO mode, and then we won't be iterating on any link. Use for_each_sta_active_link() instead, as it handles also the case of non-MLO mode.
--- .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 52 ++++++++----------- 1 file changed, 22 insertions(+), 30 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +22 -30
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* -* Copyright (C) 2012-2014, 2018-2022 Intel Corporation +* Copyright (C) 2012-2014, 2018-2023 Intel Corporation * Copyright (C) 2013-2015 Intel Mobile Communications GmbH * Copyright (C) 2016-2017 Intel Deutschland GmbH */
@@ -3607,7 +3607,8 @@ static bool iwl_mvm_vif_conf_from_sta(struct iwl_mvm *mvm,struct ieee80211_vif *vif, struct ieee80211_sta *sta) { - unsigned int i; + struct ieee80211_link_sta *link_sta; +unsigned int link_id;/* Beacon interval check - firmware will crash if the beacon * interval is less than 16. We can't avoid connecting at all,
@@ -3616,14 +3617,11 @@ static bool iwl_mvm_vif_conf_from_sta(struct iwl_mvm *mvm,* wpa_s will blocklist the AP... */ -for_each_set_bit (i, (unsigned long *)&sta->valid_links, -IEEE80211_MLD_MAX_NUM_LINKS ) { -struct ieee80211_link_sta *link_sta = -link_sta_dereference_protected (sta, i); +for_each_sta_active_link (vif, sta, link_sta, link_id) {struct ieee80211_bss_conf *link_conf = -link_conf_dereference_protected (vif, i); +link_conf_dereference_protected (vif, link_id); -if (!link_conf || !link_sta) +if (!link_conf)continue ;if (link_conf->beacon_int <IWL_MVM_MIN_BEACON_INTERVAL_TU ) {
@@ -3645,24 +3643,23 @@ static void iwl_mvm_vif_set_he_support(struct ieee80211_hw *hw, bool is_sta) {struct iwl_mvm_vif *mvmvif =iwl_mvm_vif_from_mac80211 (vif); -unsigned int i; +struct ieee80211_link_sta *link_sta; +unsigned int link_id; -for_each_set_bit (i, (unsigned long *)&sta->valid_links, -IEEE80211_MLD_MAX_NUM_LINKS ) { -struct ieee80211_link_sta *link_sta = -link_sta_dereference_protected (sta, i); +for_each_sta_active_link (vif, sta, link_sta, link_id) {struct ieee80211_bss_conf *link_conf = -link_conf_dereference_protected (vif, i); +link_conf_dereference_protected (vif, link_id); -if (!link_conf || !link_sta || !mvmvif->link[i]) +if (!link_conf || !mvmvif->link[link_id])continue ; link_conf->he_support = link_sta->he_cap.has_he;if (is_sta) { - mvmvif->link[i]->he_ru_2mhz_block = false; + mvmvif->link[link_id]->he_ru_2mhz_block = false;if (link_sta->he_cap.has_he) -iwl_mvm_check_he_obss_narrow_bw_ru (hw, vif, i, +iwl_mvm_check_he_obss_narrow_bw_ru (hw, vif, + link_id, link_conf); } }
@@ -3675,6 +3672,7 @@ iwl_mvm_sta_state_notexist_to_none(struct iwl_mvm *mvm, struct iwl_mvm_sta_state_ops *callbacks) {struct iwl_mvm_vif *mvmvif =iwl_mvm_vif_from_mac80211 (vif); +struct ieee80211_link_sta *link_sta;unsigned int i;int ret;
@@ -3699,15 +3697,9 @@ iwl_mvm_sta_state_notexist_to_none(struct iwl_mvm *mvm, NL80211_TDLS_SETUP); } -for (i =0 ; i <ARRAY_SIZE (sta->link); i++) { -struct ieee80211_link_sta *link_sta; - - link_sta =link_sta_dereference_protected (sta, i); -if (!link_sta) -continue ; - +for_each_sta_active_link (vif, sta, link_sta, i) link_sta->agg.max_rc_amsdu_len =1 ; - } +ieee80211_sta_recalc_aggregates (sta);if (vif->type ==NL80211_IFTYPE_STATION && !sta->tdls)
@@ -3725,7 +3717,8 @@ iwl_mvm_sta_state_auth_to_assoc(struct ieee80211_hw *hw, {struct iwl_mvm_vif *mvmvif =iwl_mvm_vif_from_mac80211 (vif);struct iwl_mvm_sta *mvm_sta =iwl_mvm_sta_from_mac80211 (sta); -unsigned int i; +struct ieee80211_link_sta *link_sta; +unsigned int link_id;lockdep_assert_held (&mvm->mutex);
@@ -3751,14 +3744,13 @@ iwl_mvm_sta_state_auth_to_assoc(struct ieee80211_hw *hw,if (!mvm->mld_api_is_used) goto out; -for_each_set_bit (i, (unsigned long *)&sta->valid_links, -IEEE80211_MLD_MAX_NUM_LINKS ) { +for_each_sta_active_link (vif, sta, link_sta, link_id) {struct ieee80211_bss_conf *link_conf = -link_conf_dereference_protected (vif, i); +link_conf_dereference_protected (vif, link_id);if (WARN_ON (!link_conf))return -EINVAL ; -if (!mvmvif->link[i]) +if (!mvmvif->link[link_id])continue ; iwl_mvm_link_changed(mvm, vif, link_conf,
Signature · 1 line
2.38.1
PATCH 12/12 wifi: iwlwifi: mvm: Add locking to the rate read flow
In reply to [email protected]From: Ariel Malamud <[email protected]>
The rs_drv_get_rate flow reads the lq_sta to return the optimal rate for tx frames. This read flow is not protected thereby leaving a small window, a few instructions wide, open to contention by an asynchronous rate update. Indeed this race condition was hit and the update occurred in the middle of the read.
Fix this by locking the lq_sta struct during read.
--- drivers/net/wireless/intel/iwlwifi/mvm/rs.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/intel/iwlwifi/mvm/rs.c +3 -0
@@ -2691,6 +2691,8 @@ static void rs_drv_get_rate(void *mvm_r, struct ieee80211_sta *sta,return ; lq_sta = mvm_sta; + +spin_lock (&lq_sta->pers.lock);iwl_mvm_hwrate_to_tx_rate_v1 (lq_sta->last_rate_n_flags, info->band, &info->control.rates[0 ]); info->control.rates[0 ].count =1 ;
@@ -2705,6 +2707,7 @@ static void rs_drv_get_rate(void *mvm_r, struct ieee80211_sta *sta,iwl_mvm_hwrate_to_tx_rate_v1 (last_ucode_rate, info->band, &txrc->reported_rate); } +spin_unlock (&lq_sta->pers.lock); } static void *rs_drv_alloc_sta(void *mvm_rate, struct ieee80211_sta *sta,
Signature · 1 line
2.38.1