Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH wireless] wifi: mac80211: fix use-after-free in ieee80211_rx_h_data()
@ 2026-11-25 22:15 Elkin Cruz
  0 siblings, 0 replies; only message in thread
From: Elkin Cruz @ 2026-11-25 22:15 UTC (permalink / raw)
  To: Johannes Berg
  Cc: linux-wireless, linux-kernel, llvm, irogers, Elkin Cruz, stable

In ieee80211_rx_h_data(), tf caches rx->skb->data before calling
pskb_may_pull(). When pskb_may_pull() reallocates rx->skb->head to pull
nonlinear fragments, tf->payload_type, tf->category, and
tf->action_code dereference freed memory.

Ensure pskb_may_pull() succeeds before reading through tf, and derive
tf from rx->skb->data only after pulling.

Fixes: 8a4d32f30d11 ("mac80211: add TDLS channel-switch Rx flow")
Cc: stable@vger.kernel.org
Signed-off-by: Elkin Cruz <elkin@google.com>
---

I am trying out new Clang static analysis checks for kernel bug
classes, and they flagged this code as possibly buggy. The findings
were triaged/fixed and commit descriptions were drafted with help of AI,
then checked against linux-next (not runtime-tested on hardware).

Thanks,
Elkin

 net/mac80211/rx.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index a2356cd17691..f97d7f4daa79 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -3292,12 +3292,11 @@ ieee80211_rx_h_data(struct ieee80211_rx_data *rx)
 
 	/* directly handle TDLS channel switch requests/responses */
 	if (unlikely(((struct ethhdr *)rx->skb->data)->h_proto ==
-						cpu_to_be16(ETH_P_TDLS))) {
+						cpu_to_be16(ETH_P_TDLS)) &&
+	    pskb_may_pull(rx->skb, offsetof(struct ieee80211_tdls_data, u))) {
 		struct ieee80211_tdls_data *tf = (void *)rx->skb->data;
 
-		if (pskb_may_pull(rx->skb,
-				  offsetof(struct ieee80211_tdls_data, u)) &&
-		    tf->payload_type == WLAN_TDLS_SNAP_RFTYPE &&
+		if (tf->payload_type == WLAN_TDLS_SNAP_RFTYPE &&
 		    tf->category == WLAN_CATEGORY_TDLS &&
 		    (tf->action_code == WLAN_TDLS_CHANNEL_SWITCH_REQUEST ||
 		     tf->action_code == WLAN_TDLS_CHANNEL_SWITCH_RESPONSE)) {
-- 
2.56.1.839.g22a8290db9-goog


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

only message in thread, other threads:[~2026-11-25 22:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 22:15 [PATCH wireless] wifi: mac80211: fix use-after-free in ieee80211_rx_h_data() Elkin Cruz

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