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

From: netdev-bot+sashiko

Date: Sat Nov 28 2026 - 23:54:26 EST


Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The fix is incomplete.

--

wifi: mac80211: do not copy the mesh RSN IE twice into the beacon

This patch makes mesh_add_rsn_ie() search only the part of the mesh IE
blob that comes before the first vendor element. An RSN element placed
behind a vendor element is then no longer emitted by both
mesh_add_rsn_ie() and mesh_add_vendor_ies(). The search bound is clamped
to ifmsh->ie_len, because ifmsh->ie_len is a u8 that can be truncated
from the netlink attribute length.

Link: https://lore.kernel.org/all/20261124003526.78471-2-piyus@xxxxxxxxxxx/

> diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
> index 8f88141253758..c86be97bc9219 100644
> --- a/net/mac80211/mesh.c
> +++ b/net/mac80211/mesh.c
> @@ -377,14 +377,32 @@ int mesh_add_vendor_ies(struct ieee80211_sub_if_data *sdata,

[ ... ]

> + prefix = ieee80211_ie_split_vendor(ifmsh->ie, ifmsh->ie_len, 0);
> + prefix = min_t(size_t, prefix, ifmsh->ie_len);
> +
> /* find RSN IE */
> - data = cfg80211_find_ie(WLAN_EID_RSN, ifmsh->ie, ifmsh->ie_len);
> + data = cfg80211_find_ie(WLAN_EID_RSN, ifmsh->ie, prefix);

[Severity: High]
Do the two helpers still use the same boundary when the split position
is 256 or more?

mesh_add_vendor_ies() stores the same ieee80211_ie_split_vendor() result
in a u8:

net/mac80211/mesh.c:mesh_add_vendor_ies() {
u8 offset, len;
...
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);
}
}

As the new comment says, the split can return a value past
ifmsh->ie_len when ifmsh->ie_len was truncated. Suppose that value is
256:

mesh_add_rsn_ie() clamps prefix to ifmsh->ie_len.

mesh_add_vendor_ies() wraps offset to 0 and copies the whole
[0, ie_len) range verbatim.

Here is an example. A JOIN_MESH with a 511-byte NL80211_MESH_SETUP_IE
leaves ifmsh->ie_len at 255 after copy_mesh_setup(). The blob is laid
out like this:

offset 0: RSN, len 252 (254 bytes)
offset 254: non-vendor element, len 0 (2 bytes)
offset 256: non-vendor element, len 253 (255 bytes)

The split walk goes 0 -> 254 -> 256 and returns 256. Then:

mesh_add_rsn_ie() gets prefix = 255, finds the RSN element and emits
254 bytes.

mesh_add_vendor_ies() gets offset = (u8)256 = 0 and emits another 255
bytes, which contain the same RSN element.

ieee80211_mesh_build_beacon() reserves ifmsh->ie_len bytes only once in
tail_len, and then does:

bcn->tail_len = skb->len;
memcpy(bcn->tail, skb->data, bcn->tail_len);

Wouldn't this be the same slab-out-of-bounds write in
ieee80211_mesh_build_beacon(), even with no vendor element in the blob?

This route also existed before the patch. However, the commit message
says:

Search only the part of the blob that comes before the first vendor
element, so the two emitters cover disjoint ranges and their combined
output fits the budget.

The note below the fold also says:

This patch is safe without it: the clamp makes the bound no wider than
ifmsh->ie_len whatever ifmsh->ie_len happens to be.

The patch is tagged for stable as a standalone fix. A backport of only
this patch would therefore still leave the overrun in place.

Could the u8 truncation itself be removed instead? One option is to
reject setup->ie_len > 255 in copy_mesh_setup(). Another is to widen
ifmsh->ie_len and the offset and len locals in mesh_add_vendor_ies() to
size_t. Either one would also make the new clamp unnecessary.

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125043805.883952-1-piyus%40iiitd.ac.in