Skip to content

Commit dcbc17a

Browse files
jmberg-intelegrumbach
authored andcommitted
iwlwifi: mvm: protect rate scaling against non-mvm IBSS stations
When the driver callback returns that it's out of space for new stations, the mac80211 IBSS code still keeps the station so it doesn't try to add it over and over again. Since the rate scaling algorithm is separate in mac80211, it also invokes the rate scaling algorithm for such stations. It doesn't know that our rate scaling algorithm is tightly integrated with the MVM code and relies on those data structures, and it cannot as the abstraction doesn't allow for it. This leads to crashes when the rate scaling algorithm tries to use uninitialized data, notably the mvmsta->vif pointer. Protect against this in the rate scaling algorithm. We cannot get good rates with such peers anyway since the firmware cannot do anything with them. This should fix https://bugzilla.kernel.org/show_bug.cgi?id=93461 CC: <[email protected]> Reported-by: Richard Taylor <[email protected]> Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Emmanuel Grumbach <[email protected]>
1 parent 9c8928f commit dcbc17a

File tree

1 file changed

+22
-2
lines changed
  • drivers/net/wireless/iwlwifi/mvm

1 file changed

+22
-2
lines changed

drivers/net/wireless/iwlwifi/mvm/rs.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,9 @@ static void rs_mac80211_tx_status(void *mvm_r,
12781278
struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
12791279
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
12801280

1281+
if (!iwl_mvm_sta_from_mac80211(sta)->vif)
1282+
return;
1283+
12811284
if (!ieee80211_is_data(hdr->frame_control) ||
12821285
info->flags & IEEE80211_TX_CTL_NO_ACK)
12831286
return;
@@ -2511,6 +2514,14 @@ static void rs_get_rate(void *mvm_r, struct ieee80211_sta *sta, void *mvm_sta,
25112514
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
25122515
struct iwl_lq_sta *lq_sta = mvm_sta;
25132516

2517+
if (sta && !iwl_mvm_sta_from_mac80211(sta)->vif) {
2518+
/* if vif isn't initialized mvm doesn't know about
2519+
* this station, so don't do anything with the it
2520+
*/
2521+
sta = NULL;
2522+
mvm_sta = NULL;
2523+
}
2524+
25142525
/* TODO: handle rate_idx_mask and rate_idx_mcs_mask */
25152526

25162527
/* Treat uninitialized rate scaling data same as non-existing. */
@@ -2827,6 +2838,9 @@ static void rs_rate_update(void *mvm_r,
28272838
(struct iwl_op_mode *)mvm_r;
28282839
struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
28292840

2841+
if (!iwl_mvm_sta_from_mac80211(sta)->vif)
2842+
return;
2843+
28302844
/* Stop any ongoing aggregations as rs starts off assuming no agg */
28312845
for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++)
28322846
ieee80211_stop_tx_ba_session(sta, tid);
@@ -3587,9 +3601,15 @@ static ssize_t iwl_dbgfs_ss_force_write(struct iwl_lq_sta *lq_sta, char *buf,
35873601

35883602
MVM_DEBUGFS_READ_WRITE_FILE_OPS(ss_force, 32);
35893603

3590-
static void rs_add_debugfs(void *mvm, void *mvm_sta, struct dentry *dir)
3604+
static void rs_add_debugfs(void *mvm, void *priv_sta, struct dentry *dir)
35913605
{
3592-
struct iwl_lq_sta *lq_sta = mvm_sta;
3606+
struct iwl_lq_sta *lq_sta = priv_sta;
3607+
struct iwl_mvm_sta *mvmsta;
3608+
3609+
mvmsta = container_of(lq_sta, struct iwl_mvm_sta, lq_sta);
3610+
3611+
if (!mvmsta->vif)
3612+
return;
35933613

35943614
debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir,
35953615
lq_sta, &rs_sta_dbgfs_scale_table_ops);

0 commit comments

Comments
 (0)