mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH wireless] wifi: nxpwifi: fix UAF after skb_realloc_headroom() in bridged RX
@ 2026-11-25 21:01 Elkin Cruz
  0 siblings, 0 replies; only message in thread
From: Elkin Cruz @ 2026-11-25 21:01 UTC (permalink / raw)
  To: Jeff Chen, Johannes Berg
  Cc: Francesco Dolcini, linux-wireless, linux-kernel, llvm, irogers,
	Elkin Cruz, stable

In nxpwifi_uap_queue_bridged_pkt(), uap_rx_pd and rx_pkt_hdr point into
the original skb->data buffer. If skb_headroom(skb) is less than
NXPWIFI_MIN_DATA_HEADER_LEN, skb_realloc_headroom() allocates a new skb
and kfree_skb() frees the old skb, leaving uap_rx_pd and rx_pkt_hdr
dangling when updating station and bridge statistics (in addition to
rx_pkt_hdr->eth803_hdr.h_source having been partially overwritten in the
SNAP-to-Ethernet-II header move).

Cache rx_rate and ht_info from uap_rx_pd once packet bounds are verified
and read h_source and h_dest via p_ethhdr = (void *)skb->data after the
headroom reallocation block.

Fixes: 73b01e57ed3e ("wifi: nxp: add nxpwifi driver for IW61x")
Cc: stable@vger.kernel.org
Signed-off-by: Elkin Cruz <elkin@google.com>
---

I am trying out new Clang static analysis checks for kernel bug
classes, and they flagged this code as possibly buggy. The findings
were triaged/fixed and commit descriptions were drafted with help of AI,
then checked against linux-next (not runtime-tested on hardware).

Thanks,
Elkin

 drivers/net/wireless/nxp/nxpwifi/uap_txrx.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/nxp/nxpwifi/uap_txrx.c b/drivers/net/wireless/nxp/nxpwifi/uap_txrx.c
index 840dddfc4f5a..c3191575db17 100644
--- a/drivers/net/wireless/nxp/nxpwifi/uap_txrx.c
+++ b/drivers/net/wireless/nxp/nxpwifi/uap_txrx.c
@@ -84,6 +84,7 @@ nxpwifi_uap_queue_bridged_pkt(struct nxpwifi_private *priv,
 	int hdr_chop;
 	struct ethhdr *p_ethhdr;
 	struct nxpwifi_sta_node *src_node;
+	u8 rx_rate, ht_info;
 	int index;
 
 	uap_rx_pd = (struct uap_rxpd *)(skb->data);
@@ -105,6 +106,9 @@ nxpwifi_uap_queue_bridged_pkt(struct nxpwifi_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,
@@ -178,18 +182,19 @@ nxpwifi_uap_queue_bridged_pkt(struct nxpwifi_private *priv,
 	tx_info->bss_type = priv->bss_type;
 	tx_info->flags |= NXPWIFI_BUF_FLAG_BRIDGED_PKT;
 
+	p_ethhdr = (void *)skb->data;
 	rcu_read_lock();
-	src_node = nxpwifi_get_sta_entry(priv, rx_pkt_hdr->eth803_hdr.h_source);
+	src_node = nxpwifi_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;
 	}
 	rcu_read_unlock();
 
-	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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-25 21:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 21:01 [PATCH wireless] wifi: nxpwifi: fix UAF after skb_realloc_headroom() in bridged RX Elkin Cruz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®