net: korina: remove busy skb free
Subsystems (2)
PATCH 1/1 net: korina: remove busy skb free
The ndo_start_xmit() method must not attempt to free the skb to transmit when returning NETDEV_TX_BUSY. Fix the korina_send_packet() function accordingly.
--- drivers/net/ethernet/korina.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/korina.c +0 -1
@@ -216,7 +216,6 @@ static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)netif_stop_queue (dev); else { dev->stats.tx_dropped++; -dev_kfree_skb_any (skb);spin_unlock_irqrestore (&lp->lock, flags);return NETDEV_TX_BUSY ;
Signature · 1 line
2.29.2
Quoted 19 lines · Vincent Stehlé
The
ndo_start_xmit()method must not attempt to free the skb to transmit when returningNETDEV_TX_BUSY. Fix thekorina_send_packet()function accordingly.Fixes ef11291bcd5f ("Add support the Korina (IDT RC32434) Ethernet MAC")Signed-off-by Vincent Stehlé <[email protected]>Cc David S. Miller <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Florian Fainelli <[email protected]>--- drivers/net/ethernet/korina.c | 1 - 1 file changed, 1 deletion(-)drivers/net/ethernet/korina.c +0
-0
drivers/net/ethernet/korina.c static int korina_send_packet(struct sk_buff *skb, struct net_device *dev) · line 221
Quoted 7 lines
drivers/net/ethernet/korina.c +0
-1@@ -216,7 +216,6 @@ static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)netif_stop_queue (dev); else { dev->stats.tx_dropped++; -dev_kfree_skb_any (skb);spin_unlock_irqrestore (&lp->lock, flags);return NETDEV_TX_BUSY ;
As this skb is returned to the stack (and not dropped), the tx_dropped statistics increment looks bogus too.
Jakub Kicinski
maintainerQuoted 11 lines · On Mon, 14 Dec 2020 11:03:12 +0100 Julian Wiedmann wrote:
Quoted 11 lines
drivers/net/ethernet/korina.c +0
-1@@ -216,7 +216,6 @@ static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)netif_stop_queue (dev); else { dev->stats.tx_dropped++; -dev_kfree_skb_any (skb);spin_unlock_irqrestore (&lp->lock, flags);
Quoted 5 lines
drivers/net/ethernet/korina.c static int korina_send_packet(struct sk_buff *skb, struct net_device *dev) · line 221
Quoted 2 lines
drivers/net/ethernet/korina.c +0
-0return NETDEV_TX_BUSY ;As this skb is returned to the stack (and not dropped), the
tx_droppedstatistics increment looks bogus too.
Since this is clearly an ugly use after free, and nobody complained we can assume that the driver correctly stops its TX queue ahead of time. So perhaps we can change the return value to NETDEV_TX_OK instead.
Quoted 18 lines · Jakub Kicinski
Quoted 11 lines · On Mon, 14 Dec 2020 11:03:12 +0100 Julian Wiedmann wrote:
Quoted 11 lines
drivers/net/ethernet/korina.c +0
-1@@ -216,7 +216,6 @@ static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)netif_stop_queue (dev); else { dev->stats.tx_dropped++; -dev_kfree_skb_any (skb);spin_unlock_irqrestore (&lp->lock, flags);Quoted 5 lines
drivers/net/ethernet/korina.c static int korina_send_packet(struct sk_buff *skb, struct net_device *dev) · line 221
Quoted 2 lines
drivers/net/ethernet/korina.c +0
-0return NETDEV_TX_BUSY ;As this skb is returned to the stack (and not dropped), the
tx_droppedstatistics increment looks bogus too.
Quoted 3 lines
Since this is clearly an ugly use after free, and nobody complained we can assume that the driver correctly stops its TX queue ahead of time. So perhaps we can change the return value to
NETDEV_TX_OKinstead.
Hi Jakub,
Thanks for the review.
Ok, if this is the preferred fix I will respin the patch this way.
Best regards,
Vincent.
PATCH v2 1/1 net: korina: fix return value
In reply to Jakub KicinskiThe ndo_start_xmit() method must not attempt to free the skb to transmit when returning NETDEV_TX_BUSY. Therefore, make sure the korina_send_packet() function returns NETDEV_TX_OK when it frees a packet.
---
Changes since v1:
- Keep freeing the packet but return NETDEV_TX_OK, as suggested by Jakub
drivers/net/ethernet/korina.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/korina.c +1 -1
@@ -219,7 +219,7 @@ static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)dev_kfree_skb_any (skb);spin_unlock_irqrestore (&lp->lock, flags); -return NETDEV_TX_BUSY ; +return NETDEV_TX_OK ; } }
Signature · 1 line
2.29.2
Jakub Kicinski
maintainerRe: [PATCH v2] net: korina: fix return value
Quoted 9 lines · On Mon, 14 Dec 2020 23:09:52 +0100 Vincent Stehlé wrote:
The
ndo_start_xmit()method must not attempt to free the skb to transmit when returningNETDEV_TX_BUSY. Therefore, make sure thekorina_send_packet()function returnsNETDEV_TX_OKwhen it frees a packet.Fixes ef11291bcd5f ("Add support the Korina (IDT RC32434) Ethernet MAC")Suggested-by Jakub Kicinski <[email protected]>Signed-off-by Vincent Stehlé <[email protected]>Cc David S. Miller <[email protected]>Cc Florian Fainelli <[email protected]>
Let me CC Florian's more recent email just in case he wants to review.
Quoted 20 lines
Changes since v1:
- Keep freeing the packet but returnNETDEV_TX_OK, as suggested by Jakubdrivers/net/ethernet/korina.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/korina.c +1
-1@@ -219,7 +219,7 @@ static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)dev_kfree_skb_any (skb);spin_unlock_irqrestore (&lp->lock, flags); -return NETDEV_TX_BUSY ; +return NETDEV_TX_OK ; } }
Florian Fainelli
Acked-byRe: [PATCH v2] net: korina: fix return value
Quoted 5 lines · Jakub Kicinski
Quoted 4 lines · On Mon, 14 Dec 2020 23:09:52 +0100 Vincent Stehlé wrote:
The
ndo_start_xmit()method must not attempt to free the skb to transmit when returningNETDEV_TX_BUSY. Therefore, make sure thekorina_send_packet()function returnsNETDEV_TX_OKwhen it frees a packet.
Quoted 7 lines
Quoted 5 lines
Fixes ef11291bcd5f ("Add support the Korina (IDT RC32434) Ethernet MAC")Suggested-by Jakub Kicinski <[email protected]>Signed-off-by Vincent Stehlé <[email protected]>Cc David S. Miller <[email protected]>Cc Florian Fainelli <[email protected]>Let me CC Florian's more recent email just in case he wants to review.
Signature · 1 line
Florian
Re: [PATCH v2] net: korina: fix return value
Quoted 12 lines · On Wed, 16 Dec 2020 13:32:26 -0800 Florian Fainelli wrote:
Quoted 11 lines · Jakub Kicinski
Quoted 9 lines · On Mon, 14 Dec 2020 23:09:52 +0100 Vincent Stehlé wrote:
The
ndo_start_xmit()method must not attempt to free the skb to transmit when returningNETDEV_TX_BUSY. Therefore, make sure thekorina_send_packet()function returnsNETDEV_TX_OKwhen it frees a packet.Fixes ef11291bcd5f ("Add support the Korina (IDT RC32434) Ethernet MAC")Suggested-by Jakub Kicinski <[email protected]>Signed-off-by Vincent Stehlé <[email protected]>Cc David S. Miller <[email protected]>Cc Florian Fainelli <[email protected]>
Quoted 3 lines
Quoted 1 line
Let me CC Florian's more recent email just in case he wants to review.
Acked-by Florian Fainelli <[email protected]>
😬
Applied, thanks!
Quoted 1 line · Julian Wiedmann
On 13.12.20 18:20, Vincent Stehlé wrote:
...
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/korina.c +0
-1@@ -216,7 +216,6 @@ static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)netif_stop_queue (dev); else { dev->stats.tx_dropped++; -dev_kfree_skb_any (skb);spin_unlock_irqrestore (&lp->lock, flags);
Quoted 5 lines
drivers/net/ethernet/korina.c static int korina_send_packet(struct sk_buff *skb, struct net_device *dev) · line 221
Quoted 2 lines
drivers/net/ethernet/korina.c +0
-0return NETDEV_TX_BUSY ;As this skb is returned to the stack (and not dropped), the
tx_droppedstatistics increment looks bogus too.
Hi Julian,
Thanks for the review.
I will respin the patch to remove the statistics increment as well.
Best regards,
Vincent.