Linux wireless drivers development
 help / color / mirror / Atom feed
From: Elkin Cruz <elkin@google.com>
To: Brian Norris <briannorris@chromium.org>
Cc: Francesco Dolcini <francesco@dolcini.it>,
	linux-wireless@vger.kernel.org,
	 Johannes Berg <johannes@sipsolutions.net>,
	linux-kernel@vger.kernel.org,  llvm@lists.linux.dev,
	irogers@google.com, Elkin Cruz <elkin@google.com>,
	 stable@vger.kernel.org
Subject: [PATCH wireless 1/3] wifi: mwifiex: fix UAF after skb_realloc_headroom() in bridged RX
Date: Wed, 25 Nov 2026 21:00:36 +0000	[thread overview]
Message-ID: <20261125210038.1277960-2-elkin@google.com> (raw)
In-Reply-To: <20261125210038.1277960-1-elkin@google.com>

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@vger.kernel.org
Signed-off-by: Elkin Cruz <elkin@google.com>
---
 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


  reply	other threads:[~2026-11-25 21:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 21:00 [PATCH wireless 0/3] wifi: mwifiex: fix UAF and ext scan TLV bounds checks Elkin Cruz
2026-11-25 21:00 ` Elkin Cruz [this message]
2026-11-25 21:00 ` [PATCH wireless 2/3] wifi: mwifiex: check TLV header size in ext scan report Elkin Cruz
2026-11-25 21:00 ` [PATCH wireless 3/3] wifi: mwifiex: validate ext scan event envelope and TLV lengths Elkin Cruz

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=20261125210038.1277960-2-elkin@google.com \
    --to=elkin@google.com \
    --cc=briannorris@chromium.org \
    --cc=francesco@dolcini.it \
    --cc=irogers@google.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