From: Masashi Honma <masashi.honma@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: johannes@sipsolutions.net, Masashi Honma <masashi.honma@gmail.com>
Subject: [PATCH 2/3] Fix overread in PREP frame processing
Date: Sat, 9 May 2026 07:59:04 +0900 [thread overview]
Message-ID: <20260508225905.29998-2-masashi.honma@gmail.com> (raw)
In-Reply-To: <20260508225905.29998-1-masashi.honma@gmail.com>
When the AF flag is enabled, hwmp_prep_frame_process() overreads orig_addr
by 2 bytes. Since this occurs within the socket buffer, it does not read across
memory boundaries and therefore poses no security risk; however, we will fix it
as a precaution.
In this fix, a new function mesh_path_parse_reply_frame() is established to
separate the implementation of frame format validation and the check for
unsupported features. This is intended to facilitate future work when
implementing the currently unsupported parts.
Assisted-by: Claude:Sonnet 4.6
Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
---
net/mac80211/mesh.h | 1 +
net/mac80211/mesh_hwmp.c | 24 ++++++++++++++++++++++--
net/mac80211/parse.c | 7 +++++--
3 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h
index 331d2d774196..aba7ef59195a 100644
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -318,6 +318,7 @@ mpp_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx);
void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop);
void mesh_path_expire(struct ieee80211_sub_if_data *sdata);
u8 mesh_path_parse_request_frame(const u8 *pos, u8 elen);
+u8 mesh_path_parse_reply_frame(const u8 *pos, u8 elen);
void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
struct ieee80211_mgmt *mgmt, size_t len);
struct mesh_path *
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 4239412d12c7..9f903a2408f7 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -949,6 +949,25 @@ u8 mesh_path_parse_request_frame(const u8 *pos, u8 elen)
return 0;
}
+/* IEEE Std 802.11-2016 9.4.2.114 PREP element */
+u8 mesh_path_parse_reply_frame(const u8 *pos, u8 elen)
+{
+ u8 expected_len;
+
+ expected_len = 1 /* Flags */ + 1 /* Hop Count */ + 1 /* Element TTL */ +
+ 6 /* Target Mesh STA Address */ +
+ 4 /* Target HWMP Sequence Number */ +
+ (AE_F_SET(pos) ? 6 : 0) /* Target External Address */ +
+ 4 /* Lifetime */ + 4 /* Metric */ +
+ 6 /* Originator Mesh STA Address */ +
+ 4 /* Originator HWMP Sequence Number */;
+
+ if (unlikely(elen != expected_len))
+ return IEEE80211_PARSE_ERR_BAD_ELEM_SIZE;
+
+ return 0;
+}
+
void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
struct ieee80211_mgmt *mgmt, size_t len)
{
@@ -996,9 +1015,10 @@ void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
path_metric);
}
if (elems->prep) {
- if (elems->prep_len != 31)
- /* Right now we support no AE */
+ /* Right now we do not support AE (Address Extension) */
+ if (AE_F_SET(elems->prep))
goto free;
+
path_metric = hwmp_route_info_get(sdata, mgmt, elems->prep,
MPATH_PREP);
if (path_metric)
diff --git a/net/mac80211/parse.c b/net/mac80211/parse.c
index 7a2abe676361..cdc549055242 100644
--- a/net/mac80211/parse.c
+++ b/net/mac80211/parse.c
@@ -554,8 +554,11 @@ _ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params,
}
break;
case WLAN_EID_PREP:
- elems->prep = pos;
- elems->prep_len = elen;
+ elem_parse_failed = mesh_path_parse_reply_frame(pos, elen);
+ if (likely(!elem_parse_failed)) {
+ elems->prep = pos;
+ elems->prep_len = elen;
+ }
break;
case WLAN_EID_PERR:
elems->perr = pos;
--
2.43.0
next prev parent reply other threads:[~2026-05-08 22:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <8f0a2488540f4a65ea4d837a06225a27a10cc305.camel@sipsolutions.net>
2026-05-08 22:59 ` [PATCH 1/3] Fix overread in PREQ frame processing Masashi Honma
2026-05-08 22:59 ` Masashi Honma [this message]
2026-05-08 22:59 ` [PATCH 3/3] Fix PERR " Masashi Honma
2026-05-09 9:17 ` [PATCH 1/3] Fix overread in PREQ " Johannes Berg
2026-05-09 23:41 ` Masashi Honma
2026-05-09 23:41 ` [PATCH 2/3] Fix overread in PREP " Masashi Honma
2026-05-09 23:41 ` [PATCH 3/3] Fix PERR " Masashi Honma
2026-05-11 7:47 ` [PATCH 1/3] Fix overread in PREQ " Johannes Berg
2026-05-11 8:58 ` Masashi Honma
2026-05-11 9:01 ` Johannes Berg
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=20260508225905.29998-2-masashi.honma@gmail.com \
--to=masashi.honma@gmail.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@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