* [PATCH wireless v2] wifi: mac80211: store the mesh IE blob's length without truncating it
@ 2026-11-25 4:38 Piyus Kedia
2026-11-25 4:43 ` netdev-bot+sinfo
0 siblings, 1 reply; 3+ messages in thread
From: Piyus Kedia @ 2026-11-25 4:38 UTC (permalink / raw)
To: Johannes Berg, linux-wireless; +Cc: netdev, linux-kernel, Kapil Vaswani, stable
struct ieee80211_if_mesh keeps the length of the user's mesh IE blob in a
u8, and copy_mesh_setup() assigns it from a size_t that the netlink policy
allows to reach IEEE80211_MAX_DATA_LEN:
[NL80211_MESH_SETUP_IE] =
NLA_POLICY_VALIDATE_FN(NLA_BINARY, validate_ie_attr,
IEEE80211_MAX_DATA_LEN),
...
if (setup->ie_len) {
new_ie = kmemdup(setup->ie, setup->ie_len, GFP_KERNEL);
...
ifmsh->ie_len = setup->ie_len;
So the buffer holds the whole blob and the field holds the low eight bits
of its length. Three things follow, and none of them is cosmetic.
A blob whose length is a multiple of 256 stores a length of zero, and both
builders return early on "!ifmsh->ie_len" - a secure mesh silently drops
its RSN element, from a configuration the kernel accepted.
The stored length also no longer describes the blob: it can fall inside an
element. ieee80211_ie_split_vendor() walks one whole element at a time,
while (pos < ielen && ies[pos] != WLAN_EID_VENDOR_SPECIFIC)
pos += 2 + ies[pos + 1];
so with a truncated ielen it steps over the element that crosses the
truncated end and returns a position past ielen. A 257-byte RSN element
followed by a three-byte element gives nla_len 260 and ifmsh->ie_len 4,
and the split returns 257.
And the beacon builder budgets the truncated length while copying what was
actually assembled:
tail_len = ... + ifmsh->ie_len;
bcn = kzalloc(sizeof(*bcn) + head_len + tail_len, GFP_KERNEL);
skb = __dev_alloc_skb(max(head_len, tail_len), GFP_KERNEL);
...
bcn->tail_len = skb->len;
memcpy(bcn->tail, skb->data, bcn->tail_len);
The builders' skb_tailroom() checks bound only that scratch skb, whose head
the allocator rounds up, so an emit larger than tail_len passes them and
the memcpy writes past the kzalloc()ed block. In the peering frames that
mesh_plink_frame_tx() builds the skb IS the frame and is sized from the
same u8 field, so there the same over-long emit is refused by the tailroom
check and the frame is dropped - a failure, not a corruption.
Store the length as the size_t it is, and widen the two locals that derive
from it: offset and len in mesh_add_vendor_ies(), and len in
mesh_add_rsn_ie(), which truncated a 257-byte element to one byte and a
256-byte element to zero. With the field holding the real length, the
length again describes the blob validate_ie_attr() framed, the split
cannot overshoot it, and both the beacon budget and the peering-frame
budget are the size of what the builders may emit.
Fixes: 082ebb0c258d ("mac80211: fix mesh beacon format")
Cc: stable@vger.kernel.org
Signed-off-by: Kapil Vaswani <kapil@presceralabs.ai>
Signed-off-by: Piyus Kedia <piyus@iiitd.ac.in>
---
Link: https://lore.kernel.org/all/20261124003526.78471-3-piyus@iiitd.ac.in/
This applies on top of the v2 of the other patch of the v1 series, "wifi:
mac80211: do not copy the mesh RSN IE twice into the beacon", which is posted
in its own thread and answers its own review. Each patch of the v1 series
drew a review of its own, so each is respun separately.
Changes in v2, all from the review of v1:
- THE PREMISE WAS FALSE AND THE PATCH WAS UNSAFE WITHOUT IT. v1 said "the
extra IE blob a mesh join carries is bounded by IEEE80211_MAX_DATA_LEN,
2304 bytes, and ifmsh->ie_len is a size_t", and the field is a u8. The
review showed what that cost: widening the RSN length to unsigned int
REMOVED the truncation that had been accidentally containing the copy, so
a 257-byte RSN element behind a 4-byte stored length went from emitting
one byte to emitting all 257 into a four-byte budget. v1's closing
"Neither is a memory-safety problem" was wrong in the one direction that
matters.
- So v2 fixes the field rather than only the locals: struct
ieee80211_if_mesh::ie_len becomes the size_t that struct mesh_setup and
the nl80211 policy already use. That is the first of the three remedies
the review offered, and it is the one that makes the stored length
describe the blob again - after which ieee80211_ie_split_vendor() cannot
overshoot it, the beacon budget is the size of what may be emitted, and
the peering-frame budget in mesh_plink_frame_tx(), which is sized from the
same field, is too.
- The subject and the commit message are rewritten around that. v1
described vendor elements starting past byte 255 reaching
mesh_add_vendor_ies(), which the review correctly points out cannot
happen - the truncation is at the struct field, earlier than v1 said.
- Two further consequences the review found are now stated: a blob whose
length is a multiple of 256 stores zero, so a secure mesh silently drops
its RSN element; and widening offset is not a no-op either, since the old
u8 wrapped on an overshooting split and copied a few bytes where nothing
is copied now.
- Fixes: is now 082ebb0c258d ("mac80211: fix mesh beacon format") rather
than 2b5e19677592 ("mac80211: cache mesh beacon"). Confirmed by reading
082ebb0c258d: it is the commit that added "u8 offset, len" to
mesh_add_vendor_ies() and "u8 len = 0" to mesh_add_rsn_ie(), and the
truncation predates the beacon caching and reaches the peering frames as
well. The review is right that this decides which stable trees take it.
Measured, and not: the beacon overrun this series is about was reproduced on
mainline 7.4-rc3 and on 7.3.1, with KASAN reporting a slab-out-of-bounds
write in ieee80211_mesh_build_beacon(). The truncation routes the review
found - the multiple-of-256 blob, and the 257-byte element with a four-byte
stored length - come from reading the code and have NOT been run here.
mesh.c, cfg.c and mesh_plink.c all build clean, and checkpatch --strict
reports nothing.
---
net/mac80211/ieee80211_i.h | 2 +-
net/mac80211/mesh.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 7a64aef6890d..e0f1bc0a618f 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -826,7 +826,7 @@ struct ieee80211_if_mesh {
int num_gates;
struct beacon_data __rcu *beacon;
const u8 *ie;
- u8 ie_len;
+ size_t ie_len;
enum {
IEEE80211_MESH_SEC_NONE = 0x0,
IEEE80211_MESH_SEC_AUTHED = 0x1,
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index c86be97bc921..940af399343a 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -354,7 +354,7 @@ int mesh_add_vendor_ies(struct ieee80211_sub_if_data *sdata,
struct sk_buff *skb)
{
struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
- u8 offset, len;
+ size_t offset, len;
const u8 *data;
if (!ifmsh->ie || !ifmsh->ie_len)
@@ -378,7 +378,7 @@ int mesh_add_rsn_ie(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
{
struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
size_t prefix;
- u8 len = 0;
+ unsigned int len;
const u8 *data;
if (!ifmsh->ie || !ifmsh->ie_len)
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH wireless v2] wifi: mac80211: store the mesh IE blob's length without truncating it
2026-11-25 4:38 [PATCH wireless v2] wifi: mac80211: store the mesh IE blob's length without truncating it Piyus Kedia
@ 2026-11-25 4:43 ` netdev-bot+sinfo
2026-11-25 5:06 ` Piyus Kedia
0 siblings, 1 reply; 3+ messages in thread
From: netdev-bot+sinfo @ 2026-11-25 4:43 UTC (permalink / raw)
To: Piyus Kedia
Cc: Johannes Berg, linux-wireless, netdev, linux-kernel,
Kapil Vaswani, stable
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH wireless v2] wifi: mac80211: store the mesh IE blob's length without truncating it
2026-11-25 4:43 ` netdev-bot+sinfo
@ 2026-11-25 5:06 ` Piyus Kedia
0 siblings, 0 replies; 3+ messages in thread
From: Piyus Kedia @ 2026-11-25 5:06 UTC (permalink / raw)
To: netdev-bot+sinfo
Cc: Johannes Berg, linux-wireless, netdev, linux-kernel,
Kapil Vaswani, stable
Hi!
The bot is right, and the information is in this posting - but under the ---
line, where git am drops it, so it is missing from the commit message itself.
Stating it here as asked, rather than reposting:
How it was found: by AI-driven fuzzing built on top of syzkaller. A generated
program put a vendor element followed by an RSN element in
NL80211_MESH_SETUP_IE on a mesh interface, and KASAN reported a
slab-out-of-bounds write in ieee80211_mesh_build_beacon(), reproduced on
mainline 7.4-rc3 and on 7.3.1.
That run is what found the beacon-tail overflow fixed by the other patch of
this series, "wifi: mac80211: do not copy the mesh RSN IE twice into the
beacon". The truncating "ifmsh->ie_len = setup->ie_len" that this patch is
about was found by reading the code around that crash, and by the review of
v1 of this patch, which showed that v1 made the overflow reachable rather than
fixing it. The two routes the commit message describes - a blob length that
is a multiple of 256, and a 257-byte element behind a truncated stored length
- come from reading the code and have not been run here.
If there is a v3 for other reasons, that paragraph will be in the commit
message.
On Wed, Nov 25, 2026 at 10:13 AM <netdev-bot+sinfo@kernel.org> wrote:
>
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
> - How the issue was discovered, e.g. hit in production, hit during
> development, syzbot report, manual code inspection, LLM or static
> analysis tool scan.
>
> Please do not repost the series just to address the above. Instead,
> reply to this email with the missing information, so that reviewers
> can take it into account.
>
> *IMPORTANT*: If you do repost (for other reasons) - please include
> the relevant info in the cover letter or commit messages.
> --
> The evaluation is done by an LLM so it may be wrong, if you think
> that is the case please reply and explain.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-25 5:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 4:38 [PATCH wireless v2] wifi: mac80211: store the mesh IE blob's length without truncating it Piyus Kedia
2026-11-25 4:43 ` netdev-bot+sinfo
2026-11-25 5:06 ` Piyus Kedia
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®