linux/drivers/net/wireless
Norbert van Bolhuis 07c020c6d1 wifi: brcmfmac: Fix oops due to NULL pointer dereference in brcmf_sdiod_sglist_rw()
[ Upstream commit 857282b819 ]

This patch fixes a NULL pointer dereference bug in brcmfmac that occurs
when a high 'sd_sgentry_align' value applies (e.g. 512) and a lot of queued SKBs
are sent from the pkt queue.

The problem is the number of entries in the pre-allocated sgtable, it is
nents = max(rxglom_size, txglom_size) + max(rxglom_size, txglom_size) >> 4 + 1.
Given the default [rt]xglom_size=32 it's actually 35 which is too small.
Worst case, the pkt queue can end up with 64 SKBs. This occurs when a new SKB
is added for each original SKB if tailroom isn't enough to hold tail_pad.
At least one sg entry is needed for each SKB. So, eventually the "skb_queue_walk loop"
in brcmf_sdiod_sglist_rw may run out of sg entries. This makes sg_next return
NULL and this causes the oops.

The patch sets nents to max(rxglom_size, txglom_size) * 2 to be able handle
the worst-case.
Btw. this requires only 64-35=29 * 16 (or 20 if CONFIG_NEED_SG_DMA_LENGTH) = 464
additional bytes of memory.

Signed-off-by: Norbert van Bolhuis <nvbolhuis@gmail.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://patch.msgid.link/20241107132903.13513-1-nvbolhuis@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2024-12-14 20:00:08 +01:00
..
admtek wifi: mac80211: add wake_tx_queue callback to drivers 2022-10-10 11:00:03 +02:00
ath wifi: ath5k: add PCI ID for Arcadyan devices 2024-12-14 20:00:05 +01:00
atmel Fix nomenclature for USB and PCI wireless devices 2023-08-25 12:56:49 +03:00
broadcom wifi: brcmfmac: Fix oops due to NULL pointer dereference in brcmf_sdiod_sglist_rw() 2024-12-14 20:00:08 +01:00
cisco wifi: airo: avoid uninitialized warning in airo_get_rate() 2023-07-11 19:22:54 -07:00
intel wifi: ipw2x00: libipw_rx_any(): fix bad alignment 2024-12-14 20:00:08 +01:00
intersil wifi: p54: Use IRQF_NO_AUTOEN flag in request_irq() 2024-12-09 10:32:00 +01:00
legacy Fix nomenclature for USB and PCI wireless devices 2023-08-25 12:56:49 +03:00
marvell wifi: mwifiex: Fix memcpy() field-spanning write warning in mwifiex_config_scan() 2024-12-09 10:32:04 +01:00
mediatek wifi: mt76: mt7915: hold dev->mt76.mutex while disabling tx worker 2024-10-10 11:57:28 +02:00
microchip wifi: radiotap: Avoid -Wflex-array-member-not-at-end warnings 2024-12-09 10:31:35 +01:00
purelifi wifi: plfxlc: check for allocation failure in plfxlc_usb_wreq_async() 2024-01-25 15:35:19 -08:00
quantenna wifi: qtnfmac: use struct_size and size_sub for payload length 2023-03-13 15:44:29 +02:00
ralink wifi: rt2x00: correct wrong BBP register in RxDCOC calibration 2024-02-05 20:14:18 +00:00
realtek wifi: rtw89: check return value of ieee80211_probereq_get() for RNR 2024-12-14 20:00:02 +01:00
rsi wifi: rsi: rsi_91x_usb_ops: Remove unnecessary (void*) conversions 2023-08-23 14:07:16 +03:00
silabs wifi: wfx: Fix error handling in wfx_core_init() 2024-12-09 10:32:07 +01:00
st wifi: cw1200: Avoid processing an invalid TIM IE 2024-08-29 17:33:24 +02:00
ti wifi: wlcore: sdio: Use module_sdio_driver macro to simplify the code 2023-08-25 12:59:31 +03:00
virtual wifi: radiotap: Avoid -Wflex-array-member-not-at-end warnings 2024-12-09 10:31:35 +01:00
zydas Fix nomenclature for USB and PCI wireless devices 2023-08-25 12:56:49 +03:00
Kconfig wifi: move raycs, wl3501 and rndis_wlan to legacy directory 2023-03-13 15:42:14 +02:00
Makefile wifi: move raycs, wl3501 and rndis_wlan to legacy directory 2023-03-13 15:42:14 +02:00