From: Miri Korenblit miriam.rachel.korenblit@intel.com
[ Upstream commit 1373f94148a5adac2f42c8ba9771105624fe4af0 ]
We currently don't count the reg connection length in the per-link capability length. Fix it.
Reviewed-by: Johannes Berg johannes.berg@intel.com Signed-off-by: Miri Korenblit miriam.rachel.korenblit@intel.com Link: https://patch.msgid.link/20250826202512.b14fc82f736b.I03442382e8a07f6f9836bc... Signed-off-by: Johannes Berg johannes.berg@intel.com Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
YES
- What the change fixes: The size estimator for per-link capability elements in association/ML frames failed to account for the 6 GHz “regulatory connectivity” element. The patch adds 4 bytes for this element when operating on 6 GHz, ensuring the pre-allocation size matches what is actually written. - Change site: net/mac80211/mlme.c:2125 adds the missing size accounting in `ieee80211_link_common_elems_size(...)`, specifically: - Adds `size += 2 + 1 + sizeof(struct ieee80211_he_6ghz_capa);` and now also - Adds `size += 4; /* reg connection */` for 6 GHz (net/mac80211/mlme.c:2125–2129). - Why it matters: The element is always emitted for non-AP STAs on 6 GHz and has a fixed size of 4 bytes, so not counting it underestimates the SKB size and can lead to tailroom underruns. - The element writer `ieee80211_put_reg_conn(...)` emits exactly 4 bytes (Extension IE header + ext ID + 1-octet value): net/mac80211/util.c:2569–2573. - This writer is called for 6 GHz links in `ieee80211_add_link_elems(...)`: net/mac80211/mlme.c:1876–1880. - Where the size is used: The total buffer for management frames is precomputed and passed to `alloc_skb(size, GFP_KERNEL)`. Underestimation here risks overrun when later appending IEs. - Association request path: `ieee80211_send_assoc(...)` sums `ieee80211_link_common_elems_size(...)` into `size` before `alloc_skb(size, GFP_KERNEL)` (net/mac80211/mlme.c:2167–2184, 2217–2219). - ML reconfiguration frames also use this helper for their per-link STA profiles (net/mac80211/mlme.c:10481–10485). - User impact: On 6 GHz connections (HE/EHT, especially with MLO), the missing 4 bytes can cause: - Buffer tailroom underrun during frame construction (possible KASAN/BUG/WARN or memory corruption). - Malformed frames leading to association or ML reconfiguration failures. - Scope and risk: - Small, self-contained fix in mac80211 mgmt path; no API/ABI change; no feature addition. - Only affects 6 GHz cases where the element is actually sent; over- allocation by 4 bytes in other contexts does not occur. - Very low regression risk; it corrects a precise accounting bug to match already-emitted bytes.
Stable backport criteria: - Fixes a real bug that can affect users on 6 GHz. - Minimal, targeted change; no architectural changes. - Low risk of regressions; strictly improves size correctness.
Conclusion: This should be backported to all stable kernels that include `ieee80211_put_reg_conn()` and use `ieee80211_link_common_elems_size()` for SKB sizing in association/ML frames.
net/mac80211/mlme.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index dd650a127a317..f38881b927d17 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -2112,8 +2112,11 @@ ieee80211_link_common_elems_size(struct ieee80211_sub_if_data *sdata, sizeof(struct ieee80211_he_mcs_nss_supp) + IEEE80211_HE_PPE_THRES_MAX_LEN;
- if (sband->band == NL80211_BAND_6GHZ) + if (sband->band == NL80211_BAND_6GHZ) { size += 2 + 1 + sizeof(struct ieee80211_he_6ghz_capa); + /* reg connection */ + size += 4; + }
size += 2 + 1 + sizeof(struct ieee80211_eht_cap_elem) + sizeof(struct ieee80211_eht_mcs_nss_supp) +