Commit 9cc88678 authored by Johannes Berg's avatar Johannes Berg

wifi: mac80211: check SSID in beacon

Check that the SSID in beacons is correct, if it's not hidden
and beacon protection is enabled (otherwise there's no value).
If it doesn't match, disconnect.
Reviewed-by: default avatarMiriam Rachel Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20240612143809.8b24a3d26a3d.I3e3ef31dbd2ec606be74d502a9d00dd9514c6885@changeidSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 0b2d9d9a
...@@ -6667,6 +6667,29 @@ ieee80211_mgd_check_cross_link_csa(struct ieee80211_sub_if_data *sdata, ...@@ -6667,6 +6667,29 @@ ieee80211_mgd_check_cross_link_csa(struct ieee80211_sub_if_data *sdata,
} }
} }
static bool ieee80211_mgd_ssid_mismatch(struct ieee80211_sub_if_data *sdata,
const struct ieee802_11_elems *elems)
{
struct ieee80211_vif_cfg *cfg = &sdata->vif.cfg;
static u8 zero_ssid[IEEE80211_MAX_SSID_LEN];
if (!elems->ssid)
return false;
/* hidden SSID: zero length */
if (elems->ssid_len == 0)
return false;
if (elems->ssid_len != cfg->ssid_len)
return true;
/* hidden SSID: zeroed out */
if (memcmp(elems->ssid, zero_ssid, elems->ssid_len))
return false;
return memcmp(elems->ssid, cfg->ssid, cfg->ssid_len);
}
static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link, static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link,
struct ieee80211_hdr *hdr, size_t len, struct ieee80211_hdr *hdr, size_t len,
struct ieee80211_rx_status *rx_status) struct ieee80211_rx_status *rx_status)
...@@ -6808,6 +6831,15 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link, ...@@ -6808,6 +6831,15 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link,
elems = ieee802_11_parse_elems_full(&parse_params); elems = ieee802_11_parse_elems_full(&parse_params);
if (!elems) if (!elems)
return; return;
if (rx_status->flag & RX_FLAG_DECRYPTED &&
ieee80211_mgd_ssid_mismatch(sdata, elems)) {
sdata_info(sdata, "SSID mismatch for AP %pM, disconnect\n",
sdata->vif.cfg.ap_addr);
__ieee80211_disconnect(sdata);
return;
}
ncrc = elems->crc; ncrc = elems->crc;
if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK) && if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK) &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment