Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH v2] wifi: mac80211: validate individual TWT params before driver setup
@ 2026-07-23  1:09 Zhao Li
  0 siblings, 0 replies; only message in thread
From: Zhao Li @ 2026-07-23  1:09 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, linux-kernel, lachlan.hodges, lorenzo, Zhao Li

ieee80211_process_rx_twt_action() validates a received S1G TWT setup
frame only through the control byte and 2-byte req_type 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.

No in-tree driver both implements .add_twt_setup and exposes S1G
operation, so this is a robustness fix rather than a fix for an observed
crash.

Fixes: f5a4c24e689f ("mac80211: introduce individual TWT support in AP mode")
Cc: Lachlan Hodges <lachlan.hodges@morsemicro.com>
Cc: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/all/20260708195911.84365-7-enderaoelyther@gmail.com/
Assisted-by: Codex:gpt-5
Assisted-by: Claude:opus-4.8
Signed-off-by: Zhao Li <enderaoelyther@gmail.com>
---
Changes in v2:
  - Validate the full parameter block only for individual agreements,
    leaving broadcast rejection handling unchanged.
  - Add the relevant driver maintainers.

 net/mac80211/s1g.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/mac80211/s1g.c b/net/mac80211/s1g.c
index 5af4a0c6c642..abc338e22e59 100644
--- a/net/mac80211/s1g.c
+++ b/net/mac80211/s1g.c
@@ -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 */
-- 
2.50.1 (Apple Git-155)

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-23  1:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-23  1:09 [PATCH v2] wifi: mac80211: validate individual TWT params before driver setup Zhao Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox