wifi: rtw88: fix OOB read from firmware RX descriptor exceeding DMA buffer
PATCH v3 1/1 wifi: rtw88: fix OOB read from firmware RX descriptor exceeding DMA buffer
From: Tristan Madani <[email protected]>
In rtw_pci_rx_napi(), new_len is computed as the sum of pkt_len (14-bit descriptor field, max 16383) and pkt_offset (drv_info_sz + shift, both firmware-controlled). The result can exceed RTK_PCI_RX_BUF_SIZE (11478), causing an out-of-bounds read from the pre-allocated DMA buffer when skb_put_data copies new_len bytes. The USB transport already validates this (rtw_usb_rx_data_put checks against RTW_USB_MAX_RECVBUF_SZ); the PCIe path does not.
Add a check that new_len does not exceed the DMA buffer size.
---
Changes in v3:
- Wrap check in unlikely() since this is the RX hot path, per Ping-Ke Shih.
Changes in v2:
- Clarify field widths and maximum new_len derivation in commit message, per Ping-Ke Shih.
drivers/net/wireless/realtek/rtw88/pci.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/realtek/rtw88/pci.c +5 -0
@@ -1077,6 +1077,11 @@ static u32 rtw_pci_rx_napi(struct rtw_dev *rtwdev, struct rtw_pci *rtwpci,* discard the frame if none available */ new_len = pkt_stat.pkt_len + pkt_offset; +if (unlikely (new_len >RTK_PCI_RX_BUF_SIZE )) { +rtw_dbg (rtwdev,RTW_DBG_RX , +"oversized RX packet: %u\n" , new_len); + goto next_rp; + } new =dev_alloc_skb (new_len);if (WARN_ONCE (!new,"rx routine starvation\n" )) goto next_rp;
Signature · 1 line
2.47.3
Ping-Ke Shih
maintainerQuoted 10 lines · Tristan Madani
From: Tristan Madani <[email protected]>
In
rtw_pci_rx_napi(),new_lenis computed as the sum ofpkt_len(14-bit descriptor field, max 16383) andpkt_offset(drv_info_sz+ shift, both firmware-controlled). The result can exceedRTK_PCI_RX_BUF_SIZE(11478), causing an out-of-bounds read from the pre-allocated DMA buffer whenskb_put_datacopiesnew_lenbytes. The USB transport already validates this (rtw_usb_rx_data_putchecks againstRTW_USB_MAX_RECVBUF_SZ); the PCIe path does not.
Quoted 4 lines
Add a check that
new_lendoes not exceed the DMA buffer size.Fixes e3037485c68e ("rtw88: new Realtek 802.11ac driver")Signed-off-by Tristan Madani <[email protected]>
1 patch(es) applied to rtw-next branch of rtw.git, thanks.
6e76e9ed273d wifi: rtw88: fix OOB read from firmware RX descriptor exceeding DMA buffer