[PATCH v2] wifi: libertas: reject short monitor TX frames

Kai Kuang kuangkai at kylinos.cn
Mon Nov 16 04:18:05 PST 2026


In monitor mode, lbs_hard_start_xmit() casts skb->data to a radiotap TX
header, skips that header and then copies the 802.11 destination address
from offset 4 in the remaining frame.  The generic length check only
rejects zero-length and oversized skbs, so a short monitor frame is read
past the end of the skb data.  If the frame is shorter than the radiotap
header, the subtraction that computes pkt_len also underflows, turning
the following memcpy() into a large out-of-bounds read of the skb and a
write past the end of tx_pending_buf.

Require enough bytes for the radiotap TX header and the destination
address field before using the monitor-mode header layout.  The check
runs while driver_lock is held and before the TX queues are stopped, so
the drop path reuses the existing "goto free" cleanup; placing it after
the lock is dropped would unlock driver_lock twice and leave
tx_pending_len set to -1 with the queues stopped.

This addresses the same out-of-bounds read that the earlier submission
linked below was meant to fix, but was reverted because it performed the
check after driver_lock had already been released.

Link: https://patch.msgid.link/20260704011140.37639-1-pengpeng@iscas.ac.cn
Signed-off-by: Kai Kuang <kuangkai at kylinos.cn>
---
Dropped the comments.

 drivers/net/wireless/marvell/libertas/tx.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/wireless/marvell/libertas/tx.c b/drivers/net/wireless/marvell/libertas/tx.c
index 27304a98787d..23d68df1f61c 100644
--- a/drivers/net/wireless/marvell/libertas/tx.c
+++ b/drivers/net/wireless/marvell/libertas/tx.c
@@ -88,6 +88,13 @@ netdev_tx_t lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 		goto free;
 	}
 
+	if (priv->wdev->iftype == NL80211_IFTYPE_MONITOR &&
+	    skb->len < sizeof(struct tx_radiotap_hdr) + 4 + ETH_ALEN) {
+		lbs_deb_tx("tx err: short monitor frame %d\n", skb->len);
+		dev->stats.tx_dropped++;
+		dev->stats.tx_errors++;
+		goto free;
+	}
 
 	netif_stop_queue(priv->dev);
 	if (priv->mesh_dev)
-- 
2.25.1




More information about the libertas-dev mailing list