]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: mac80211: validate individual TWT params before driver setup
authorZhao Li <enderaoelyther@gmail.com>
Thu, 23 Jul 2026 01:09:28 +0000 (09:09 +0800)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 28 Jul 2026 13:34:31 +0000 (15:34 +0200)
ieee80211_process_rx_twt_action() only partially validates a received
S1G TWT setup frame before queueing it.

An individual agreement can therefore reach ieee80211_s1g_rx_twt_setup()
with twt->length too short for the full struct ieee80211_twt_params.

The individual path passes twt to drv_add_twt_setup(). Both the tracepoint
and the driver callback consume the complete parameters block, not merely
req_type. Do not pass a short individual agreement to the driver.
Broadcast agreements remain unchanged because they are rejected locally
after accessing only req_type.

Fixes: f5a4c24e689f ("mac80211: introduce individual TWT support in AP mode")
Assisted-by: Codex:gpt-5
Assisted-by: Claude:opus-4.8
Signed-off-by: Zhao Li <enderaoelyther@gmail.com>
Link: https://patch.msgid.link/20260723010928.76551-1-enderaoelyther@gmail.com
[edit commit message to not overclaim lack of validation nor
 understate driver impact]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/s1g.c

index 5af4a0c6c6424b4b9dfd6c6e5d9e13b6c8b94b27..abc338e22e59cc297cfd02f06c9e01d41a9c916a 100644 (file)
@@ -101,6 +101,10 @@ ieee80211_s1g_rx_twt_setup(struct ieee80211_sub_if_data *sdata,
        struct ieee80211_twt_setup *twt = (void *)mgmt->u.action.s1g.variable;
        struct ieee80211_twt_params *twt_agrt = (void *)twt->params;
 
+       if (!(twt->control & IEEE80211_TWT_CONTROL_NEG_TYPE_BROADCAST) &&
+           twt->length < sizeof(twt->control) + sizeof(*twt_agrt))
+               return;
+
        twt_agrt->req_type &= cpu_to_le16(~IEEE80211_TWT_REQTYPE_REQUEST);
 
        /* broadcast TWT not supported yet */