Skip to content

Commit ab9177d

Browse files
committed
wifi: mac80211: don't use rate mask for scanning
The rate mask is intended for use during operation, and can be set to only have masks for the currently active band. As such, it cannot be used for scanning which can be on other bands as well. Simply ignore the rate masks during scanning to avoid warnings from incorrect settings. Reported-by: syzbot+fdc5123366fb9c3fdc6d@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=fdc5123366fb9c3fdc6d Co-developed-by: Dmitry Antipov <dmantipov@yandex.ru> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Tested-by: Dmitry Antipov <dmantipov@yandex.ru> Link: https://msgid.link/20240326220854.9594cbb418ca.I7f86c0ba1f98cf7e27c2bacf6c2d417200ecea5c@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 7c1c73b commit ab9177d

4 files changed

Lines changed: 18 additions & 5 deletions

File tree

include/net/mac80211.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,8 @@ enum mac80211_tx_info_flags {
953953
* of their QoS TID or other priority field values.
954954
* @IEEE80211_TX_CTRL_MCAST_MLO_FIRST_TX: first MLO TX, used mostly internally
955955
* for sequence number assignment
956+
* @IEEE80211_TX_CTRL_SCAN_TX: Indicates that this frame is transmitted
957+
* due to scanning, not in normal operation on the interface.
956958
* @IEEE80211_TX_CTRL_MLO_LINK: If not @IEEE80211_LINK_UNSPECIFIED, this
957959
* frame should be transmitted on the specific link. This really is
958960
* only relevant for frames that do not have data present, and is
@@ -973,6 +975,7 @@ enum mac80211_tx_control_flags {
973975
IEEE80211_TX_CTRL_NO_SEQNO = BIT(7),
974976
IEEE80211_TX_CTRL_DONT_REORDER = BIT(8),
975977
IEEE80211_TX_CTRL_MCAST_MLO_FIRST_TX = BIT(9),
978+
IEEE80211_TX_CTRL_SCAN_TX = BIT(10),
976979
IEEE80211_TX_CTRL_MLO_LINK = 0xf0000000,
977980
};
978981

net/mac80211/rate.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,7 @@ void ieee80211_get_tx_rates(struct ieee80211_vif *vif,
877877
struct ieee80211_sub_if_data *sdata;
878878
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
879879
struct ieee80211_supported_band *sband;
880+
u32 mask = ~0;
880881

881882
rate_control_fill_sta_table(sta, info, dest, max_rates);
882883

@@ -889,9 +890,12 @@ void ieee80211_get_tx_rates(struct ieee80211_vif *vif,
889890
if (ieee80211_is_tx_data(skb))
890891
rate_control_apply_mask(sdata, sta, sband, dest, max_rates);
891892

893+
if (!(info->control.flags & IEEE80211_TX_CTRL_SCAN_TX))
894+
mask = sdata->rc_rateidx_mask[info->band];
895+
892896
if (dest[0].idx < 0)
893897
__rate_control_send_low(&sdata->local->hw, sband, sta, info,
894-
sdata->rc_rateidx_mask[info->band]);
898+
mask);
895899

896900
if (sta)
897901
rate_fixup_ratelist(vif, sband, info, dest, max_rates);

net/mac80211/scan.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ static void ieee80211_send_scan_probe_req(struct ieee80211_sub_if_data *sdata,
648648
cpu_to_le16(IEEE80211_SN_TO_SEQ(sn));
649649
}
650650
IEEE80211_SKB_CB(skb)->flags |= tx_flags;
651+
IEEE80211_SKB_CB(skb)->control.flags |= IEEE80211_TX_CTRL_SCAN_TX;
651652
ieee80211_tx_skb_tid_band(sdata, skb, 7, channel->band);
652653
}
653654
}

net/mac80211/tx.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -698,11 +698,16 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
698698
txrc.bss_conf = &tx->sdata->vif.bss_conf;
699699
txrc.skb = tx->skb;
700700
txrc.reported_rate.idx = -1;
701-
txrc.rate_idx_mask = tx->sdata->rc_rateidx_mask[info->band];
702701

703-
if (tx->sdata->rc_has_mcs_mask[info->band])
704-
txrc.rate_idx_mcs_mask =
705-
tx->sdata->rc_rateidx_mcs_mask[info->band];
702+
if (unlikely(info->control.flags & IEEE80211_TX_CTRL_SCAN_TX)) {
703+
txrc.rate_idx_mask = ~0;
704+
} else {
705+
txrc.rate_idx_mask = tx->sdata->rc_rateidx_mask[info->band];
706+
707+
if (tx->sdata->rc_has_mcs_mask[info->band])
708+
txrc.rate_idx_mcs_mask =
709+
tx->sdata->rc_rateidx_mcs_mask[info->band];
710+
}
706711

707712
txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP ||
708713
tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||

0 commit comments

Comments
 (0)