mirror of
https://github.com/morrownr/8812au-20210820.git
synced 2026-10-14 21:38:30 +00:00
[PR #63] [CLOSED] core: rtw_ieee80211: guard attr_len underflow in rtw_get_wfd_attr_content #66
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/morrownr/8812au-20210820/pull/63
Author: @breakneck-git
Created: 4/26/2026
Status: ❌ Closed
Base:
main← Head:fix-p2p-wfd-attr-len-underflow📝 Commits (1)
5d98510core: rtw_ieee80211: guard attr_len underflow in rtw_get_wfd_attr_content📊 Changes
1 file changed (+15 additions, -1 deletions)
View changed files
📝
core/rtw_ieee80211.c(+15 -1)📄 Description
Summary
Guards against an integer underflow in
rtw_get_wfd_attr_content()that, on a malformed Wi-Fi-Display attribute, leads to_rtw_memcpy()writing a near-INT_MAX number of bytes into a kernel stack buffer.Why only WFD here
This fork's
rtw_get_p2p_attr_content()(same file, just above) already uses a bounds-safe pattern — callers pre-populate*len_contentwithsizeof(buf)and the function clamps the copy to that hint. Whoever did that hardening pass apparently missedrtw_get_wfd_attr_content()right below it; this PR addresses just the missed variant.The same class of bug was also submitted to:
Root cause
attr_lencarries the 3-byte WFD attribute header. The parser computesattr_len = attr_data_len + 3with both operandsu16. Whenattr_data_len >= 0xFFFD(attacker-controlled length field in frame), the addition wraps inu16to{0, 1, 2}. The parser's bounds check only catchesattr_len > wfd_ielen, not the wrap.When
attr_len < 3reaches the callee,attr_len - 3underflows inu32to a near-INT_MAX value, and_rtw_memcpy(buf_content, attr_ptr + 3, ~0xFFFFFFFE)runs.Fix
Replace
attr_lentruthiness check withattr_len >= 3(the documented minimum). When the parser returns underflowedattr_len < 3, the callee now returns NULL with*len_content == 0, matching the documented "attribute not found" return path that all callers already handle.A follow-up to mirror the P2P pattern (caller-supplied bounds via
*len_content) here would also be valid — happy to do it as a separate PR if you prefer.Test environment
0bda:0811) on Raspberry Pi 2B, kernel 6.12.47Disclosure
This patch is the result of a code-review pass conducted with the help of an LLM (Claude). The reasoning, exploit chain, and fix were verified by reading the relevant source paths exhaustively before submission. I am not a kernel engineer; please flag anything I missed.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.