Skip to contentSkip to conversation

wifi: mwifiex: zero-pad SDIO TX buffer to block-aligned transfer length

PATCH New Tristan Madani 1 participant 1 message Nov 24

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 wifi: mwifiex: zero-pad SDIO TX buffer to block-aligned transfer length

From: Tristan Madani <[email protected]>

mwifiex_sdio_host_to_card() rounds up the packet length to MWIFIEX_SDIO_BLOCK_SIZE (256 bytes) for SDIO block-mode transfers. When the original skb data is shorter than the rounded-up length, the SDIO controller reads past the valid payload into uninitialized skb tailroom, transmitting stale data to the wireless device firmware.

Zero the padding bytes starting at skb_tail_pointer() without extending skb->len, so that reused buffers such as adapter->sleep_cfm keep their original length across sends. When tailroom is smaller than the padding, zero whatever is available.

Fixes 5e6e3a92b9a4 ("wireless: mwifiex: initial commit for Marvell mwifiex driver")

---
v2: use memset(skb_tail_pointer()) instead of skb_put_zero() to avoid permanently extending skb->len on reused buffers like sleep_cfm. Use min_t() to zero whatever tailroom is available when it is smaller than the padding. (Jeff Chen)

Build tested: x86_64 defconfig + CONFIG_MWIFIEX=m + CONFIG_MWIFIEX_SDIO=m, gcc 14.2, W=1, 0 warnings.

 drivers/net/wireless/marvell/mwifiex/sdio.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/wireless/marvell/mwifiex/sdio.c +5 -0
index 417dc2649b99c..d097efb2afbee 100644
@@ -2386,6 +2386,11 @@ static int mwifiex_sdio_host_to_card(struct mwifiex_adapter *adapter,
 	/* Transfer data to card */
 	pkt_len = buf_block_len * blk_size;
 
+	if (pkt_len > skb->len)
+		memset(skb_tail_pointer(skb), 0,
+		       min_t(unsigned int, pkt_len - skb->len,
+			     skb_tailroom(skb)));
+
 	if (tx_param)
 		ret = mwifiex_host_to_card_mp_aggr(adapter, payload, pkt_len,
 						   port, tx_param->next_pkt_len
Signature · 1 line
2.47.3