From: Elkin Cruz <elkin@google.com>
To: Jeff Chen <jeff.chen_1@nxp.com>,
Johannes Berg <johannes@sipsolutions.net>
Cc: Francesco Dolcini <francesco@dolcini.it>,
linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, irogers@google.com,
Elkin Cruz <elkin@google.com>,
stable@vger.kernel.org
Subject: [PATCH wireless] wifi: nxpwifi: fix UAF after skb_realloc_headroom() in bridged RX
Date: Wed, 25 Nov 2026 21:01:58 +0000 [thread overview]
Message-ID: <20261125210158.1280227-1-elkin@google.com> (raw)
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
reply other threads:[~2026-11-25 21:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261125210158.1280227-1-elkin@google.com \
--to=elkin@google.com \
--cc=francesco@dolcini.it \
--cc=irogers@google.com \
--cc=jeff.chen_1@nxp.com \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®