[PATCH wireless 1/3] wifi: mwifiex: fix UAF after skb_realloc_headroom() in bridged RX

From: Elkin Cruz

Date: Wed Nov 25 2026 - 16:01:59 EST


In mwifiex_uap_queue_bridged_pkt(), uap_rx_pd and rx_pkt_hdr point into
the initial skb->data buffer. When skb_headroom(skb) is smaller than
MWIFIEX_MIN_DATA_HEADER_LEN, skb_realloc_headroom() allocates a new skb,
kfree_skb() frees the original skb, and skb is updated to new_skb,
leaving uap_rx_pd and rx_pkt_hdr dangling. Subsequent reads of
rx_pkt_hdr->eth803_hdr.h_source, uap_rx_pd->rx_rate, uap_rx_pd->ht_info,
and rx_pkt_hdr->eth803_hdr.h_dest dereference the freed skb (and in the
RFC1042/SNAP conversion branch, rx_pkt_hdr->eth803_hdr.h_source was also
partially overwritten in-place when constructing the Ethernet II header).

Save rx_rate and ht_info from uap_rx_pd after the packet length check
and re-derive p_ethhdr from the live skb->data after any headroom
reallocation, since skb_pull() already positioned skb->data at the
Ethernet header in both header-conversion branches.

Fixes: f7b598532f3d ("mwifiex: update statistics for bridged packets on AP interface")
Fixes: 442f6f9b49c8 ("mwifiex: maintain station statistic in uap mode")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Elkin Cruz <elkin@xxxxxxxxxx>
---
drivers/net/wireless/marvell/mwifiex/uap_txrx.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/uap_txrx.c b/drivers/net/wireless/marvell/mwifiex/uap_txrx.c
index 318bd4ed8399..d2512b985014 100644
--- a/drivers/net/wireless/marvell/mwifiex/uap_txrx.c
+++ b/drivers/net/wireless/marvell/mwifiex/uap_txrx.c
@@ -89,6 +89,7 @@ static void mwifiex_uap_queue_bridged_pkt(struct mwifiex_private *priv,
int hdr_chop;
struct ethhdr *p_ethhdr;
struct mwifiex_sta_node *src_node;
+ u8 rx_rate, ht_info;
int index;

uap_rx_pd = (struct uap_rxpd *)(skb->data);
@@ -113,6 +114,9 @@ static void mwifiex_uap_queue_bridged_pkt(struct mwifiex_private *priv,
return;
}

+ rx_rate = uap_rx_pd->rx_rate;
+ ht_info = uap_rx_pd->ht_info;
+
if ((!memcmp(&rx_pkt_hdr->rfc1042_hdr, bridge_tunnel_header,
sizeof(bridge_tunnel_header))) ||
(!memcmp(&rx_pkt_hdr->rfc1042_hdr, rfc1042_header,
@@ -183,16 +187,17 @@ static void mwifiex_uap_queue_bridged_pkt(struct mwifiex_private *priv,
tx_info->bss_type = priv->bss_type;
tx_info->flags |= MWIFIEX_BUF_FLAG_BRIDGED_PKT;

- src_node = mwifiex_get_sta_entry(priv, rx_pkt_hdr->eth803_hdr.h_source);
+ p_ethhdr = (void *)skb->data;
+ src_node = mwifiex_get_sta_entry(priv, p_ethhdr->h_source);
if (src_node) {
src_node->stats.last_rx = jiffies;
src_node->stats.rx_bytes += skb->len;
src_node->stats.rx_packets++;
- src_node->stats.last_tx_rate = uap_rx_pd->rx_rate;
- src_node->stats.last_tx_htinfo = uap_rx_pd->ht_info;
+ src_node->stats.last_tx_rate = rx_rate;
+ src_node->stats.last_tx_htinfo = ht_info;
}

- if (is_unicast_ether_addr(rx_pkt_hdr->eth803_hdr.h_dest)) {
+ if (is_unicast_ether_addr(p_ethhdr->h_dest)) {
/* Update bridge packet statistics as the
* packet is not going to kernel/upper layer.
*/
--
2.56.1.839.g22a8290db9-goog