From 0af4a66c2be190cdbe88a34621cc926611f2c3d5 Mon Sep 17 00:00:00 2001 From: Thomas Pedersen Date: Thu, 1 Oct 2020 10:47:48 -0700 Subject: [PATCH] mac80211: avoid processing non-S1G elements on S1G band In ieee80211_determine_chantype(), the sband->ht_cap was being processed before S1G Operation element. Since the HT capability element should not be present on the S1G band, avoid processing potential garbage by moving the call to ieee80211_apply_htcap_overrides() to after the S1G block. Also, in case of a missing S1G Operation element, we would continue trying to process non-S1G elements (and return with a channel width of 20MHz). Instead, just assume primary channel is equal to operating and infer the operating width from the BSS channel, then return. Signed-off-by: Thomas Pedersen Link: https://lore.kernel.org/r/20201001174748.24520-1-thomas@adapt-ip.com Signed-off-by: Johannes Berg --- net/mac80211/mlme.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 38e87ac9902e9..e9a8e8e94ee67 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -172,13 +172,13 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata, ret = 0; vht_chandef = *chandef; goto out; - } - - memcpy(&sta_ht_cap, &sband->ht_cap, sizeof(sta_ht_cap)); - ieee80211_apply_htcap_overrides(sdata, &sta_ht_cap); + } else if (sband->band == NL80211_BAND_S1GHZ) { + if (!ieee80211_chandef_s1g_oper(s1g_oper, chandef)) { + sdata_info(sdata, + "Missing S1G Operation Element? Trying operating == primary\n"); + chandef->width = ieee80211_s1g_channel_width(channel); + } - if (s1g_oper && sband->band == NL80211_BAND_S1GHZ) { - ieee80211_chandef_s1g_oper(s1g_oper, chandef); ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_40MHZ | IEEE80211_STA_DISABLE_VHT | IEEE80211_STA_DISABLE_80P80MHZ | @@ -186,6 +186,9 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata, goto out; } + memcpy(&sta_ht_cap, &sband->ht_cap, sizeof(sta_ht_cap)); + ieee80211_apply_htcap_overrides(sdata, &sta_ht_cap); + if (!ht_oper || !sta_ht_cap.ht_supported) { ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT | -- 2.39.5