Skip to content

Commit 9cc8867

Browse files
committed
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: Miriam Rachel Korenblit <[email protected]> Link: https://patch.msgid.link/20240612143809.8b24a3d26a3d.I3e3ef31dbd2ec606be74d502a9d00dd9514c6885@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent 0b2d9d9 commit 9cc8867

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

net/mac80211/mlme.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6667,6 +6667,29 @@ ieee80211_mgd_check_cross_link_csa(struct ieee80211_sub_if_data *sdata,
66676667
}
66686668
}
66696669

6670+
static bool ieee80211_mgd_ssid_mismatch(struct ieee80211_sub_if_data *sdata,
6671+
const struct ieee802_11_elems *elems)
6672+
{
6673+
struct ieee80211_vif_cfg *cfg = &sdata->vif.cfg;
6674+
static u8 zero_ssid[IEEE80211_MAX_SSID_LEN];
6675+
6676+
if (!elems->ssid)
6677+
return false;
6678+
6679+
/* hidden SSID: zero length */
6680+
if (elems->ssid_len == 0)
6681+
return false;
6682+
6683+
if (elems->ssid_len != cfg->ssid_len)
6684+
return true;
6685+
6686+
/* hidden SSID: zeroed out */
6687+
if (memcmp(elems->ssid, zero_ssid, elems->ssid_len))
6688+
return false;
6689+
6690+
return memcmp(elems->ssid, cfg->ssid, cfg->ssid_len);
6691+
}
6692+
66706693
static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link,
66716694
struct ieee80211_hdr *hdr, size_t len,
66726695
struct ieee80211_rx_status *rx_status)
@@ -6808,6 +6831,15 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link,
68086831
elems = ieee802_11_parse_elems_full(&parse_params);
68096832
if (!elems)
68106833
return;
6834+
6835+
if (rx_status->flag & RX_FLAG_DECRYPTED &&
6836+
ieee80211_mgd_ssid_mismatch(sdata, elems)) {
6837+
sdata_info(sdata, "SSID mismatch for AP %pM, disconnect\n",
6838+
sdata->vif.cfg.ap_addr);
6839+
__ieee80211_disconnect(sdata);
6840+
return;
6841+
}
6842+
68116843
ncrc = elems->crc;
68126844

68136845
if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK) &&

0 commit comments

Comments
 (0)