Re: [PATCH v4] wifi: mwifiex: validate event lengths before copying bodies
From: Zhao Li
Date: Sat Nov 21 2026 - 09:23:40 EST
On Fri, Jul 31, 2026 at 10:20:02PM +0800, Pengpeng Hou wrote:
> + if (skb->len < MWIFIEX_EVENT_HEADER_LEN ||
> + skb->len - MWIFIEX_EVENT_HEADER_LEN > MAX_EVENT_SIZE) {
One concern with v4: dropping SDIO events whose body is larger than
MAX_EVENT_SIZE (2048) would also drop events that do not use
adapter->event_body[]. SDIO command-port reads can reach 4 KiB,
and events such as EVENT_EXT_SCAN_REPORT are parsed directly from
adapter->event_skb->data. Rejecting skb->len < 4 and clamping the
memcpy() into event_body[] to MAX_EVENT_SIZE would protect event_body[]
without discarding > 2048-byte skbs.
However, clamping instead of dropping exposes a separate bug in
EVENT_RXBA_SYNC (which v4 happens to mask on SDIO). Both sta_event.c
and uap_event.c pass adapter->event_body paired with the untruncated
adapter->event_skb->len - sizeof(eventcause) as the u16 length to
mwifiex_11n_rxba_sync_event():
- When event_skb->len > 2052 (possible on SDIO, up to 4092 bytes),
the TLV walk reads past event_body[2047] into the following
mwifiex_adapter fields.
- On PCIe (untouched by v4), mwifiex_pcie_process_event_ready() has no
lower bound on evt_len: for evt_len 0..7 event_skb->len ends up at
0..3, and the u16 length argument wraps to 0xFFFC..0xFFFF.
nxpwifi (SDIO only) has the same RXBA_SYNC callers, and its SDIO copy
already clamps to MAX_EVENT_SIZE, so only the length argument is
unbounded there.
Checking event_skb->len >= sizeof(eventcause) and parsing RXBA_SYNC
from event_skb->data + sizeof(eventcause) (as the TDLS parser does)
would fix both the over-read and the u16 wrap across all transports,
without waiting for the PCIe buffer-return rework discussed in October.
Are you planning a v5, and would it make sense for me to send separate
fixes for EVENT_RXBA_SYNC in mwifiex and nxpwifi?
Thanks,
Zhao