CVE-2026-139504: wifi: mm81x: check bytes_remaining before reading delimiter
In the Linux kernel, the following vulnerability has been resolved:
wifi: mm81x: check bytesremaining before reading delimiter
mm81xyapshwreadpkts() reads a full 4-byte delimiter and then subtracts sizeof(delim) from bytesremaining on every loop iteration, guarded only by "bytesremaining > 0". If 1-3 bytes are left in the window, this reads past the end of the valid data and then subtracts 4 from a value smaller than 4, driving bytesremaining negative.
A negative bytesremaining then reaches the totallen > bytesremaining branch, where "bytesremaining" is passed to memcpy() as the copy length. Implicitly converted to sizet, a negative int becomes a huge value, turning that memcpy() into a massive out-of-bounds copy.
Bail out of the split loop once fewer than sizeof(delim) bytes remain, the same way the existing "end of stream" check bails on a zero delimiter.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In the mm81x packet-splitting loop, bail out when fewer than sizeof(delim) bytes remain before reading the delimiter.
Event History
Frequently Asked Questions
What conditions are required to trigger the out-of-bounds copy?
The packet-read loop must reach a state where only 1 to 3 bytes remain in its valid data window. It then reads a 4-byte delimiter, makes bytes_remaining negative, and can pass that negative value to memcpy() as a length.
What is the practical impact of the integer underflow?
When the negative bytes_remaining value is implicitly converted to size_t for memcpy(), it becomes a very large unsigned length. This can cause a massive out-of-bounds copy.
Is there a mitigation described for systems that cannot immediately apply the fix?
The provided data describes the code-level mitigation: stop the split loop when fewer than sizeof(delim) bytes remain, matching the existing handling for a zero delimiter. No operational workaround or configuration-based mitigation is provided.