Skip to content

Commit

Permalink
wifi: iwlwifi: mvm: Add locking to the rate read flow
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Ariel Malamud <ariel.malamud@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230514120631.b52c9ed5c379.I15290b78e0d966c1b68278263776ca9de841d5fe@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Ariel Malamud authored and Johannes Berg committed May 16, 2023
1 parent 207be64 commit a8938bc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/net/wireless/intel/iwlwifi/mvm/rs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down

0 comments on commit a8938bc

Please sign in to comment.