]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
staging: rtl8723bs: validate monitor transmit frame lengths
authorMariano Baragiola <mbaragiola@linux.com>
Mon, 27 Jul 2026 16:08:59 +0000 (13:08 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Jul 2026 07:44:42 +0000 (09:44 +0200)
rtw_cfg80211_monitor_if_xmit_entry() removes the radiotap header and
then reads the 802.11 frame control field without checking that a base
802.11 header remains.

The data path also pulls the calculated 802.11, QoS and SNAP header
span before confirming that the skb contains it. A truncated frame can
therefore cause out-of-bounds reads or leave insufficient data for the
Ethernet address writes.

Reject frames that do not contain the base 802.11 header and data
frames that do not contain their complete calculated header span.

Fixes: 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver")
Cc: stable <stable@kernel.org>
Signed-off-by: Mariano Baragiola <mbaragiola@linux.com>
Link: https://patch.msgid.link/20260727160859.1917096-1-mbaragiola@linux.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c

index 967cd1b34aed8653afd9e7ae33346edc4f9a64f2..9fa3131feb66285e000539e0fe667ea3f7f44445 100644 (file)
@@ -2033,6 +2033,8 @@ static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc
 
        /* Skip the ratio tap header */
        skb_pull(skb, rtap_len);
+       if (skb->len < dot11_hdr_len)
+               goto fail;
 
        dot11_hdr = (struct ieee80211_hdr *)skb->data;
        frame_control = le16_to_cpu(dot11_hdr->frame_control);
@@ -2045,6 +2047,8 @@ static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc
                        qos_len = 2;
                if ((frame_control & 0x0300) == 0x0300)
                        dot11_hdr_len += 6;
+               if (skb->len < dot11_hdr_len + qos_len + snap_len)
+                       goto fail;
 
                memcpy(dst_mac_addr, dot11_hdr->addr1, sizeof(dst_mac_addr));
                memcpy(src_mac_addr, dot11_hdr->addr2, sizeof(src_mac_addr));