FAILED: patch "[PATCH] wifi: mac80211: validate extension-frame layout before RX" failed to apply to 6.6-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 57d503ce32eccfa7650065ca4c560f7e29a2e676
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026072109-language-whoops-8789@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 57d503ce32eccfa7650065ca4c560f7e29a2e676 Mon Sep 17 00:00:00 2001
From: Zhao Li <[email protected]>
Date: Fri, 12 Jun 2026 00:19:45 +0800
Subject: [PATCH] wifi: mac80211: validate extension-frame layout before RX
Extension frames only have the extension header at the regular 802.11 header offset. The generic RX path can still reach helpers and interface dispatch code that read regular header address fields before unsupported extension subtypes are dropped.
mac80211 currently only handles S1G beacon extension frames. Drop other extension subtypes before they can reach regular-header RX processing. For S1G beacons, linearize the SKB with the management-frame path and require the fixed S1G beacon header, including optional fixed fields indicated by frame control, before generic RX dispatch.
Route S1G beacons through the station/default-link RX path without regular-header station lookup. Avoid regular-header address reads in the mac80211 RX paths that process S1G extension beacons, including accept-frame, duplicate-detection, address-copy, and MLO address-translation paths.
Also make ieee80211_get_bssid() length-safe before returning the S1G source-address pointer.
net/mac80211/rx.c +32 -2
@@ -1526,6 +1526,9 @@ ieee80211_rx_h_check_dup(struct ieee80211_rx_data *rx)if (status->flag &RX_FLAG_DUP_VALIDATED )return RX_CONTINUE ; +if (ieee80211_is_ext (hdr->frame_control)) +return RX_CONTINUE ; +/* * Drop duplicate 802.11 retransmissions * (IEEE 802.11-2012: 9.3.2.10 "Duplicate detection and recovery")
@@ -4510,12 +4513,16 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx)struct ieee80211_hdr *hdr = (void *)skb->data;struct ieee80211_rx_status *status =IEEE80211_SKB_RXCB (skb);u8 *bssid =ieee80211_get_bssid (hdr, skb->len, sdata->vif.type); -bool multicast =is_multicast_ether_addr (hdr->addr1) || -ieee80211_is_s1g_beacon (hdr->frame_control); +bool multicast;static const u8 nan_network_id[ETH_ALEN ]__aligned(2) = {0x51 ,0x6F ,0x9A ,0x01 ,0x00 ,0x00 }; +if (ieee80211_is_s1g_beacon (hdr->frame_control)) +return sdata->vif.type ==NL80211_IFTYPE_STATION && bssid; + + multicast =is_multicast_ether_addr (hdr->addr1); +switch (sdata->vif.type) {case NL80211_IFTYPE_STATION :if (!bssid && !sdata->u.mgd.use_4addr)
@@ -5212,6 +5219,11 @@ static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx, hdr = (struct ieee80211_hdr *)rx->skb->data; } +if (ieee80211_is_s1g_beacon (hdr->frame_control)) { +ieee80211_invoke_rx_handlers (rx); +return true; + } +/* Store a copy of the pre-translated link addresses for SW crypto */ if (unlikely (is_unicast_ether_addr (hdr->addr1) && !ieee80211_is_data (hdr->frame_control)))
@@ -5301,6 +5313,13 @@ static bool ieee80211_rx_for_interface(struct ieee80211_rx_data *rx,struct sta_info *sta;int link_id =-1 ; +if (ieee80211_is_s1g_beacon (hdr->frame_control)) { +if (!ieee80211_rx_data_set_sta (rx,NULL ,-1 )) +return false; + +return ieee80211_prepare_and_rx_handle (rx, skb, consume); + } +/* * Look up link station first, in case there's a * chance that they might have a link address that
@@ -5376,6 +5395,17 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, err = -ENOBUFS ; else err =skb_linearize (skb); + }else if (ieee80211_is_s1g_beacon (fc)) { +size_t s1g_hdr_len = offsetof(struct ieee80211_ext , + u.s1g_beacon.variable) + +ieee80211_s1g_optional_len (fc); + +if (skb->len < s1g_hdr_len) + err = -ENOBUFS ; +else + err =skb_linearize (skb); + }else if (ieee80211_is_ext (fc)) { + err = -EINVAL ; }else { err = !pskb_may_pull (skb,ieee80211_hdrlen (fc)); }
net/mac80211/util.c +3 -0
@@ -73,6 +73,9 @@ u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,if (ieee80211_is_s1g_beacon (fc)) {struct ieee80211_ext *ext = (void *) hdr; + if (len < offsetofend(struct ieee80211_ext, u.s1g_beacon.sa)) +return NULL ; +return ext->u.s1g_beacon.sa; }
PATCH 1/1 wifi: mac80211: validate extension-frame layout before RX
From: Zhao Li <[email protected]>
commit 57d503ce32eccfa7650065ca4c560f7e29a2e676 upstream.
Extension frames only have the extension header at the regular 802.11 header offset. The generic RX path can still reach helpers and interface dispatch code that read regular header address fields before unsupported extension subtypes are dropped.
mac80211 currently only handles S1G beacon extension frames. Drop other extension subtypes before they can reach regular-header RX processing. For S1G beacons, linearize the SKB with the management-frame path and require the fixed S1G beacon header, including optional fixed fields indicated by frame control, before generic RX dispatch.
Route S1G beacons through the station/default-link RX path without regular-header station lookup. Avoid regular-header address reads in the mac80211 RX paths that process S1G extension beacons, including accept-frame, duplicate-detection, address-copy, and MLO address-translation paths.
Also make ieee80211_get_bssid() length-safe before returning the S1G source-address pointer.
---
6.6 has no ieee80211_s1g_optional_len(), so the S1G header length check uses the s1g_beacon / s1g_short_beacon variable offsets, which is how 6.6 already finds the IEs in mlme.c and wireless/scan.c. The rest matches upstream and the 6.12.y backport 7aba69b61100.
Tested on v6.6.163: W=1 build of net/mac80211/rx.o and util.o, base vs patched, no new warnings. In a KVM guest, mac80211_hwsim registered a radio and wlan0 came up and down on both kernels. I didn't send S1G or malformed extension frames, so the new checks weren't hit.
The backport and the test runs were prepared with AI coding tools (OpenAI Codex agents, with review by Claude). I went over the result before signing off.
--- net/mac80211/rx.c | 34 ++++++++++++++++++++++++++++++++-- net/mac80211/util.c | 3 +++ 2 files changed, 35 insertions(+), 2 deletions(-)
net/mac80211/rx.c +32 -2
@@ -1416,6 +1416,9 @@ ieee80211_rx_h_check_dup(struct ieee80211_rx_data *rx)if (status->flag &RX_FLAG_DUP_VALIDATED )return RX_CONTINUE ; +if (ieee80211_is_ext (hdr->frame_control)) +return RX_CONTINUE ; +/* * Drop duplicate 802.11 retransmissions * (IEEE 802.11-2012: 9.3.2.10 "Duplicate detection and recovery")
@@ -4386,8 +4389,12 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx)struct ieee80211_hdr *hdr = (void *)skb->data;struct ieee80211_rx_status *status =IEEE80211_SKB_RXCB (skb);u8 *bssid =ieee80211_get_bssid (hdr, skb->len, sdata->vif.type); -bool multicast =is_multicast_ether_addr (hdr->addr1) || -ieee80211_is_s1g_beacon (hdr->frame_control); +bool multicast; + +if (ieee80211_is_s1g_beacon (hdr->frame_control)) +return sdata->vif.type ==NL80211_IFTYPE_STATION && bssid; + + multicast =is_multicast_ether_addr (hdr->addr1);switch (sdata->vif.type) {case NL80211_IFTYPE_STATION :
@@ -5026,6 +5033,11 @@ static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx, hdr = (struct ieee80211_hdr *)rx->skb->data; } +if (ieee80211_is_s1g_beacon (hdr->frame_control)) { +ieee80211_invoke_rx_handlers (rx); +return true; + } + if (unlikely(rx->sta && rx->sta->sta.mlo) && is_unicast_ether_addr(hdr->addr1) && !ieee80211_is_probe_resp(hdr->frame_control) &&
@@ -5110,6 +5122,13 @@ static bool ieee80211_rx_for_interface(struct ieee80211_rx_data *rx,struct sta_info *sta;int link_id =-1 ; +if (ieee80211_is_s1g_beacon (hdr->frame_control)) { +if (!ieee80211_rx_data_set_sta (rx,NULL ,-1 )) +return false; + +return ieee80211_prepare_and_rx_handle (rx, skb, consume); + } +/* * Look up link station first, in case there's a * chance that they might have a link address that
@@ -5169,6 +5188,17 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, err = -ENOBUFS ; else err =skb_linearize (skb); + }else if (ieee80211_is_s1g_beacon (fc)) { +size_t s1g_hdr_len =ieee80211_is_s1g_short_beacon (fc) ? + offsetof(struct ieee80211_ext, u.s1g_short_beacon.variable) : + offsetof(struct ieee80211_ext, u.s1g_beacon.variable); + +if (skb->len < s1g_hdr_len) + err = -ENOBUFS ; +else + err =skb_linearize (skb); + }else if (ieee80211_is_ext (fc)) { + err = -EINVAL ; }else { err = !pskb_may_pull (skb,ieee80211_hdrlen (fc)); }
net/mac80211/util.c +3 -0
@@ -67,6 +67,9 @@ u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,if (ieee80211_is_s1g_beacon (fc)) {struct ieee80211_ext *ext = (void *) hdr; + if (len < offsetofend(struct ieee80211_ext, u.s1g_beacon.sa)) +return NULL ; +return ext->u.s1g_beacon.sa; }
---
base-commit: e2bb30811e063ce0db964484357973b855b06572
change-id: 20261129-mac80211-s1g-66-675029d06961
Best regards,
Signature · 1 line
Dickson Wu <[email protected]>
Re: [PATCH 6.6.y] wifi: mac80211: validate extension-frame layout before RX
Quoted 1 line
[ adapted to 6.6.y: use the branch S1G beacon layouts for lengths ]
Queued for 6.6, thanks.
Signature · 2 lines
Thanks, Sasha