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

Johannes Berg johannes at sipsolutions.net
Mon Nov 16 02:36:40 PST 2026


On Mon, 2026-11-16 at 18:16 +0800, Kai Kuang wrote:
> 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>
> ---
>  drivers/net/wireless/marvell/libertas/tx.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/net/wireless/marvell/libertas/tx.c b/drivers/net/wireless/marvell/libertas/tx.c
> index 27304a98787d..6ad7a5067f2a 100644
> --- a/drivers/net/wireless/marvell/libertas/tx.c
> +++ b/drivers/net/wireless/marvell/libertas/tx.c
> @@ -88,6 +88,22 @@ netdev_tx_t lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  		goto free;
>  	}
>  
> +	/*
> +	 * A monitor frame carries a radiotap TX header followed by the
> +	 * 802.11 header; the destination address is copied from offset 4
> +	 * of the latter.  Drop frames too short for that layout instead of
> +	 * reading past the end of skb data or underflowing pkt_len.
> +	 *
> +	 * This must happen while driver_lock is held and before the queues
> +	 * are stopped, so that the "goto free" path above stays consistent.
> +	 */

You should never let LLMs write comments ...

johannes



More information about the libertas-dev mailing list