netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: ethernet: SP7021: fix a use after free of skb->len
@ 2022-05-18 17:37 Dan Carpenter
  2022-05-19 14:23 ` 呂芳騰
  2022-05-20  1:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2022-05-18 17:37 UTC (permalink / raw)
  To: Wells Lu
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Andrew Lunn, netdev, kernel-janitors

The netif_receive_skb() function frees "skb" so store skb->len before
it is freed.

Fixes: fd3040b9394c ("net: ethernet: Add driver for Sunplus SP7021")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/ethernet/sunplus/spl2sw_int.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/sunplus/spl2sw_int.c b/drivers/net/ethernet/sunplus/spl2sw_int.c
index 69b1e2e0271e..a37c9a4c281f 100644
--- a/drivers/net/ethernet/sunplus/spl2sw_int.c
+++ b/drivers/net/ethernet/sunplus/spl2sw_int.c
@@ -29,6 +29,7 @@ int spl2sw_rx_poll(struct napi_struct *napi, int budget)
 	u32 mask;
 	int port;
 	u32 cmd;
+	u32 len;
 
 	/* Process high-priority queue and then low-priority queue. */
 	for (queue = 0; queue < RX_DESC_QUEUE_NUM; queue++) {
@@ -63,10 +64,11 @@ int spl2sw_rx_poll(struct napi_struct *napi, int budget)
 			skb_put(skb, pkg_len - 4); /* Minus FCS */
 			skb->ip_summed = CHECKSUM_NONE;
 			skb->protocol = eth_type_trans(skb, comm->ndev[port]);
+			len = skb->len;
 			netif_receive_skb(skb);
 
 			stats->rx_packets++;
-			stats->rx_bytes += skb->len;
+			stats->rx_bytes += len;
 
 			/* Allocate a new skb for receiving. */
 			new_skb = netdev_alloc_skb(NULL, comm->rx_desc_buff_size);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-20  1:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-18 17:37 [PATCH net-next] net: ethernet: SP7021: fix a use after free of skb->len Dan Carpenter
2022-05-19 14:23 ` 呂芳騰
2022-05-20  1:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).