Skip to contentSkip to conversation

firewire: net: fix use after free in fwnet_finish_incoming_packet()

PATCH New Vasiliy Kovalev 1 participant 1 message Oct 22, 2025 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 firewire: net: fix use after free in fwnet_finish_incoming_packet()

From: Zhang Shurong <[email protected]>

commit 3ff256751a2853e1ffaa36958ff933ccc98c6cb5 upstream.

The netif_rx() function frees the skb so we can't dereference it to save the skb->len.

---
 drivers/firewire/net.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/firewire/net.c +4 -2
index 715e491dfbc3..8504e95ede90 100644
@@ -489,7 +489,7 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
 					bool is_broadcast, u16 ether_type)
 {
 	struct fwnet_device *dev;
-	int status;
+	int status, len;
 	__be64 guid;
 
 	switch (ether_type) {
@@ -546,13 +546,15 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
 		}
 		skb->protocol = protocol;
 	}
+
+	len = skb->len;
 	status = netif_rx(skb);
 	if (status == NET_RX_DROP) {
 		net->stats.rx_errors++;
 		net->stats.rx_dropped++;
 	} else {
 		net->stats.rx_packets++;
-		net->stats.rx_bytes += skb->len;
+		net->stats.rx_bytes += len;
 	}
 
 	return 0;
Signature · 1 line
2.50.1