Linux wireless drivers development
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: piyus@iiitd.ac.in
Cc: johannes@sipsolutions.net, linux-wireless@vger.kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	kapil@presceralabs.ai, stable@vger.kernel.org, kuba@kernel.org
Subject: Re: [PATCH wireless v2] wifi: mac80211: do not copy the mesh RSN IE twice into the beacon
Date: Sun, 29 Nov 2026 04:54:12 +0000	[thread overview]
Message-ID: <179592805216.3146.5975241126695201853@kernel.org> (raw)
In-Reply-To: <20261125043805.883952-1-piyus@iiitd.ac.in>

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@iiitd.ac.in/

> 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

      reply	other threads:[~2026-11-29  4:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  4:38 [PATCH wireless v2] wifi: mac80211: do not copy the mesh RSN IE twice into the beacon Piyus Kedia
2026-11-29  4:54 ` netdev-bot+sashiko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179592805216.3146.5975241126695201853@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=johannes@sipsolutions.net \
    --cc=kapil@presceralabs.ai \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=piyus@iiitd.ac.in \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox