mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
wifi: wilc1000: fix RX buffer OOB-write in wilc_wlan_handle_isr_ext()
wilc_wlan_handle_isr_ext() takes the RX transfer size from the
device-reported interrupt status register (a 15-bit field shifted left by 2,
up to 131068 bytes) and reads that many bytes from the device into
rx_buffer, which is only WILC_RX_BUFF_SIZE (96K) large. The wrap
check only handles the current offset; the size itself is never
compared against the buffer, so a bogus SDIO device can make the driver
OOB-write rx_buffer by up to ~32K with data it controls.
The oversized transfer also leaves rx_buffer_offset past the end of
the buffer, after which the unsigned wrap check stops working and
the overflow can repeat.
Drop any transfer whose size exceeds the RX buffer, acknowledging
the data interrupt and re-arming the RX engine so the bogus frame is
discarded and reception can continue. This also restores the
rx_buffer_offset <= WILC_RX_BUFF_SIZE invariant the wrap check
relies on.
This is not expected to change driver behavior in most cases:
without this check, an oversized transfer would most likely
corrupt neighboring kernel memory instead of completing anyway, and
the drop path performs the same interrupt acknowledgment and RX
engine re-arming as the normal path, so subsequent transfers are
received unaffected.
Discovered by Atuin - Automated Vulnerability Discovery Engine.
Fixes: c5c77ba18e ("staging: wilc1000: Add SDIO/SPI 802.11 driver")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Tianchu Chen <flynnnchen@tencent.com>
Link: https://patch.msgid.link/7c971924c6bdccf6c2f75704a5a746e9303aaf64@linux.dev
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
e6c5ed7a98
commit
c1ba7f7f18
|
|
@ -1197,6 +1197,15 @@ static void wilc_wlan_handle_isr_ext(struct wilc *wilc, u32 int_status)
|
|||
if (size <= 0)
|
||||
return;
|
||||
|
||||
/* A size exceeding the RX buffer is bogus; drop the transfer
|
||||
* instead of overflowing the buffer.
|
||||
*/
|
||||
if (size > WILC_RX_BUFF_SIZE) {
|
||||
wilc->hif_func->hif_clear_int_ext(wilc,
|
||||
DATA_INT_CLR | ENABLE_RX_VMM);
|
||||
return;
|
||||
}
|
||||
|
||||
if (WILC_RX_BUFF_SIZE - offset < size)
|
||||
offset = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user