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

From: Johannes Berg

Date: Tue Nov 24 2026 - 09:02:46 EST


On Tue, 2026-11-24 at 06:05 +0530, Piyus Kedia wrote:
> 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.
>

Please write a better commit message. This is *mostly* just stating the
obvious, as LLMs always do.

johannes