[PATCH wireless 1/2] wifi: mac80211: do not copy the mesh RSN IE twice into the beacon

From: Piyus Kedia

Date: Mon Nov 23 2026 - 19:36:02 EST


ieee80211_mesh_build_beacon() budgets the user's extra IE blob once:

tail_len = ... +
ifmsh->ie_len;

bcn = kzalloc(sizeof(*bcn) + head_len + tail_len, GFP_KERNEL);

but two of the builders that fill the tail draw from that blob.
mesh_add_vendor_ies() emits everything from the first vendor IE to the
end of it:

offset = ieee80211_ie_split_vendor(ifmsh->ie, ifmsh->ie_len, 0);

if (offset < ifmsh->ie_len) {
len = ifmsh->ie_len - offset;
data = ifmsh->ie + offset;
...
skb_put_data(skb, data, len);

while mesh_add_rsn_ie() searches the whole blob:

data = cfg80211_find_ie(WLAN_EID_RSN, ifmsh->ie, ifmsh->ie_len);

A blob that begins with a vendor IE therefore has its RSN IE emitted
twice - once inside the verbatim vendor range, once on its own - and the
tail copy runs past the allocation:

BUG: KASAN: slab-out-of-bounds in ieee80211_mesh_build_beacon+0xe3f
Write of size 479 at addr ffff88805ca1887b by task syz-executor
__asan_memcpy
ieee80211_mesh_build_beacon net/mac80211/mesh.c:1110
ieee80211_start_mesh net/mac80211/mesh.c:1187
ieee80211_join_mesh net/mac80211/cfg.c:3330
rdev_join_mesh
__cfg80211_join_mesh net/wireless/mesh.c:214
nl80211_join_mesh net/wireless/nl80211.c:15399

One NL80211_CMD_JOIN_MESH carrying such an NL80211_ATTR_IE is enough.

Confine the RSN search to the non-vendor part of the blob, so the two
builders cover disjoint ranges and their total cannot exceed the single
ifmsh->ie_len the beacon was sized with. The blob reaches us having passed
validate_ie_attr(), which walks the element chain and requires it to end
exactly at the end of the attribute, so the split returns an element
boundary that is not past ifmsh->ie_len.

An RSN IE placed behind a vendor IE is still emitted, as part of that
verbatim vendor range; nothing that a well-formed configuration sends is
dropped.

How this was found: by AI-driven fuzzing built on top of syzkaller. Its
analysis was checked by hand against the code, the fault was reproduced on
net.git main under KASAN, and the patched kernel is clean on the same
reproducer with ordinary secure-mesh beacons unaffected.

Fixes: 2b5e19677592 ("mac80211: cache mesh beacon")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Kapil Vaswani <kapil@xxxxxxxxxxxxxxx>
Signed-off-by: Piyus Kedia <piyus@xxxxxxxxxxx>
---
net/mac80211/mesh.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 8f8814125375..eb54bd98f282 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -379,12 +379,19 @@ int mesh_add_rsn_ie(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
u8 len = 0;
const u8 *data;
+ size_t prefix;

if (!ifmsh->ie || !ifmsh->ie_len)
return 0;

- /* find RSN IE */
- data = cfg80211_find_ie(WLAN_EID_RSN, ifmsh->ie, ifmsh->ie_len);
+ /* Find the RSN IE in the non-vendor part of the blob only. Everything
+ * from the first vendor IE onwards is emitted verbatim by
+ * mesh_add_vendor_ies(), and ieee80211_mesh_build_beacon() budgets
+ * ifmsh->ie_len once for both of them, so an RSN IE sitting behind a
+ * vendor IE would be copied twice and overrun the beacon's tail.
+ */
+ prefix = ieee80211_ie_split_vendor(ifmsh->ie, ifmsh->ie_len, 0);
+ data = cfg80211_find_ie(WLAN_EID_RSN, ifmsh->ie, prefix);
if (!data)
return 0;

--
2.34.1