]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: atm: fix use after free in lec_send()
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 14 Mar 2025 10:10:57 +0000 (13:10 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:30:53 +0000 (14:30 +0200)
[ Upstream commit f3009d0d6ab78053117f8857b921a8237f4d17b3 ]

The ->send() operation frees skb so save the length before calling
->send() to avoid a use after free.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/c751531d-4af4-42fe-affe-6104b34b791d@stanley.mountain
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/atm/lec.c

index 7226c784dbe0c70e4d6899634cb3821ff5a61960..ca9952c52fb5c1c775394a1ca65393a685d73c4b 100644 (file)
@@ -181,6 +181,7 @@ static void
 lec_send(struct atm_vcc *vcc, struct sk_buff *skb)
 {
        struct net_device *dev = skb->dev;
+       unsigned int len = skb->len;
 
        ATM_SKB(skb)->vcc = vcc;
        atm_account_tx(vcc, skb);
@@ -191,7 +192,7 @@ lec_send(struct atm_vcc *vcc, struct sk_buff *skb)
        }
 
        dev->stats.tx_packets++;
-       dev->stats.tx_bytes += skb->len;
+       dev->stats.tx_bytes += len;
 }
 
 static void lec_tx_timeout(struct net_device *dev, unsigned int txqueue)