wifi: zero-pad SDIO writes to avoid leaking heap data
cover wifi: zero-pad SDIO writes to avoid leaking heap data
From: Tristan Madani <[email protected]>
Several wireless drivers round up the length passed to sdio_memcpy_toio() / sdio_writesb() for alignment purposes but do not clear the padding bytes. The SDIO controller then reads past the original buffer into adjacent heap memory, sending stale kernel data to the wireless device.
Fix brcmfmac (4-byte alignment) and rsi (block alignment) by zero-filling the gap before the write.
A third patch for rtw88 hits the same class of bug but needs a rebase and will follow separately.
Tristan Madani (2):
wifi: brcmfmac: zero-pad SDIO write to 4-byte boundary
wifi: rsi: zero-pad SDIO TX to block boundary
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 3 +++ drivers/net/wireless/rsi/rsi_91x_sdio.c | 3 +++ 2 files changed, 6 insertions(+)
Signature · 1 line
2.47.3
PATCH 1/2 wifi: brcmfmac: zero-pad SDIO write to 4-byte boundary
From: Tristan Madani <[email protected]>
brcmf_sdiod_skbuff_write() rounds skb->len up to the next 4-byte boundary and passes the larger size to sdio_memcpy_toio(). The 1-3 extra bytes come from heap memory past skb->data, leaking stale kernel data to the wireless device.
Zero-fill the padding before the SDIO write.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c +3 -0
@@ -323,6 +323,9 @@ static int brcmf_sdiod_skbuff_write(struct brcmf_sdio_dev *sdiodev, req_sz = skb->len +3 ; req_sz &= (uint )~3 ; +if (req_sz > skb->len) +memset (skb->data + skb->len,0 , req_sz - skb->len); + err =sdio_memcpy_toio (func, addr, ((u8 *)(skb->data)), req_sz);if (err == -ENOMEDIUM )
Signature · 1 line
2.47.3
Re: [PATCH wireless 1/2] wifi: brcmfmac: zero-pad SDIO write to 4-byte boundary
Quoted 11 lines · Tristan Madani
From: Tristan Madani <[email protected]>
brcmf_sdiod_skbuff_write()roundsskb->lenup to the next 4-byte boundary and passes the larger size tosdio_memcpy_toio(). The 1-3 extra bytes come from heap memory pastskb->data, leaking stale kernel data to the wireless device.Zero-fill the padding before the SDIO write.
Fixes 8f13c87ccc49 ("brcmfmac: Split brcmf_sdiod_buffrw function up.")
Quoted 4 lines
Signed-off-by Tristan Madani <[email protected]>--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 3 +++ 1 file changed, 3 insertions(+)
PATCH 2/2 wifi: rsi: zero-pad SDIO TX to block boundary
In reply to Tristan MadaniFrom: Tristan Madani <[email protected]>
rsi_sdio_host_intf_write_pkt() rounds the packet length up to the SDIO block size and passes the larger length to rsi_sdio_write_register_multiple(). When the packet is not block-aligned, the SDIO controller reads past the original data into adjacent heap memory, leaking stale kernel data to the wireless device.
Zero-fill the padding before the SDIO write.
--- drivers/net/wireless/rsi/rsi_91x_sdio.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/rsi/rsi_91x_sdio.c +3 -0
@@ -772,6 +772,9 @@ static int rsi_sdio_host_intf_write_pkt(struct rsi_hw *adapter, address = (num_blocks * block_size | (queueno <<12 )); length = num_blocks * block_size; +if (length > len) +memset ((u8 *)pkt + len,0 , length - len); + status = rsi_sdio_write_register_multiple(adapter, address, (u8 *)pkt,
Signature · 1 line
2.47.3