[PATCH wireless-next v5 14/19] wifi: mac80211: filter uplink and downlink frames based on ST states

From: Pooventhiran G

Date: Wed Dec 02 2026 - 05:29:43 EST


During ST, based on the state that the non-AP MLD is currently in, there
are frame filtering conditions imposed in both uplink and downlink
directions, as per IEEE P802.11bn/D2.0, Aug 2026, subclause 11.3.1.

State 4a:
- UL/DL: All Class 3 frames except ST Execution Request and Response
frames are disallowed.

State 4b:
- UL: Class 3 data frames are disallowed.
- DL: All Class 3 data, control, management frames are disallowed.

State 4c:
- UL: All Class 3 frames except QoS Null, Control, and UHR
Reconfiguration Notify frames are disallowed.
- DL: All Class 3 frames except Data, Control, and UHR
Reconfiguration Notify frames are disallowed.

Add the filters in both tx and rx handlers to implement the conditions
to avoid exchanging those frames while the station is transitioning
'seamlessly' (state-4) to the target AP MLD. The unexpected frames will
cause out-of-state operations and leaks in the context transferred.

Signed-off-by: Pooventhiran G <pooventhiran.g@xxxxxxxxxxxxxxxx>
---
net/mac80211/drop.h | 1 +
net/mac80211/rx.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
net/mac80211/tx.c | 43 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 89 insertions(+)

diff --git a/net/mac80211/drop.h b/net/mac80211/drop.h
index f433ee17cce5..fe037c94b2ca 100644
--- a/net/mac80211/drop.h
+++ b/net/mac80211/drop.h
@@ -109,6 +109,7 @@ typedef unsigned int __bitwise ieee80211_rx_result;
R(RX_DROP_U_UNHANDLED_MGMT_STYPE) \
R(RX_DROP_U_NO_LINK) \
R(RX_DROP_U_DEFRAG_OVERFLOW) \
+ R(RX_DROP_U_SMD_FILTERED) \
/* this line for the trailing \ - add before this */

/* having two enums allows for checking ieee80211_rx_result use with sparse */
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index a2356cd17691..a152471151a9 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1628,6 +1628,50 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx)
return RX_CONTINUE;
}

+static ieee80211_rx_result debug_noinline
+ieee80211_rx_h_st_state(struct ieee80211_rx_data *rx)
+{
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
+ __le16 fc = hdr->frame_control;
+
+ if (!rx->sta ||
+ (rx->sdata->vif.type != NL80211_IFTYPE_AP &&
+ rx->sdata->vif.type != NL80211_IFTYPE_AP_VLAN) ||
+ !rx->sta->sta.smd_sta ||
+ !test_sta_flag(rx->sta, WLAN_STA_ASSOC) ||
+ is_multicast_ether_addr(hdr->addr1))
+ return RX_CONTINUE;
+
+ switch (rx->sta->st_state) {
+ case IEEE80211_STA_ST_NONE:
+ break;
+ case IEEE80211_STA_ST_PREPARED:
+ /* 4a: Class 3 disallowed except ST Execution Request */
+ if (ieee80211_is_st_exec_req(rx->skb))
+ break;
+ if (ieee80211_is_class3(rx->skb))
+ return RX_DROP_U_SMD_FILTERED;
+ break;
+ case IEEE80211_STA_ST_EXECUTING:
+ /* 4b: Class 3 Data frames disallowed */
+ if (ieee80211_is_data(fc))
+ return RX_DROP_U_SMD_FILTERED;
+ break;
+ case IEEE80211_STA_ST_DL_DRAIN:
+ /*
+ * 4c: Class 3 frames disallowed except QoS Null, Control, and
+ * UHR Reconfiguration Notify frames.
+ */
+ if (ieee80211_is_qos_nullfunc(fc) || ieee80211_is_ctl(fc) ||
+ ieee80211_is_uhr_link_reconf_notify(rx->skb))
+ break;
+ if (ieee80211_is_class3(rx->skb))
+ return RX_DROP_U_SMD_FILTERED;
+ break;
+ }
+
+ return RX_CONTINUE;
+}

static ieee80211_rx_result debug_noinline
ieee80211_rx_h_check_more_data(struct ieee80211_rx_data *rx)
@@ -4305,6 +4349,7 @@ static void ieee80211_invoke_rx_handlers(struct ieee80211_rx_data *rx)

CALL_RXH(ieee80211_rx_h_check_dup);
CALL_RXH(ieee80211_rx_h_check);
+ CALL_RXH(ieee80211_rx_h_st_state);

ieee80211_rx_reorder_ampdu(rx, &reorder_release);

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index cb9ecac25a9c..aab0f8f6bd9c 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -308,6 +308,48 @@ ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx)
return TX_CONTINUE;
}

+static ieee80211_tx_result debug_noinline
+ieee80211_tx_h_st_state(struct ieee80211_tx_data *tx)
+{
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
+ __le16 fc = hdr->frame_control;
+
+ if (!tx->sta ||
+ (tx->sdata->vif.type != NL80211_IFTYPE_AP &&
+ tx->sdata->vif.type != NL80211_IFTYPE_AP_VLAN) ||
+ !tx->sta->sta.smd_sta ||
+ !test_sta_flag(tx->sta, WLAN_STA_ASSOC) ||
+ !(tx->flags & IEEE80211_TX_UNICAST))
+ return TX_CONTINUE;
+
+ switch (tx->sta->st_state) {
+ case IEEE80211_STA_ST_NONE:
+ break;
+ case IEEE80211_STA_ST_PREPARED:
+ /* 4a: Class 3 disallowed except ST Execution Response */
+ if (ieee80211_is_st_exec_resp(tx->skb))
+ break;
+ if (ieee80211_is_class3(tx->skb))
+ return TX_DROP;
+ break;
+ case IEEE80211_STA_ST_EXECUTING:
+ /* 4b: no restriction */
+ break;
+ case IEEE80211_STA_ST_DL_DRAIN:
+ /* 4c: Class 3 disallowed except Data, Control,
+ * UHR Reconfiguration Notify
+ */
+ if (ieee80211_is_ctl(fc) || ieee80211_is_data(fc) ||
+ ieee80211_is_uhr_link_reconf_notify(tx->skb))
+ break;
+ if (ieee80211_is_class3(tx->skb))
+ return TX_DROP;
+ break;
+ }
+
+ return TX_CONTINUE;
+}
+
/* This function is called whenever the AP is about to exceed the maximum limit
* of buffered frames for power saving STAs. This situation should not really
* happen often during normal operation, so dropping the oldest buffered packet
@@ -1883,6 +1925,7 @@ static int invoke_tx_handlers_early(struct ieee80211_tx_data *tx)

CALL_TXH(ieee80211_tx_h_dynamic_ps);
CALL_TXH(ieee80211_tx_h_check_assoc);
+ CALL_TXH(ieee80211_tx_h_st_state);
CALL_TXH(ieee80211_tx_h_ps_buf);
CALL_TXH(ieee80211_tx_h_check_control_port_protocol);
CALL_TXH(ieee80211_tx_h_select_key);

--
2.34.1