netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] r8169: fix potential skb double free in an error path
@ 2020-11-05 14:28 Heiner Kallweit
  2020-11-07 20:13 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Heiner Kallweit @ 2020-11-05 14:28 UTC (permalink / raw)
  To: Jakub Kicinski, David Miller, Realtek linux nic maintainers
  Cc: netdev@vger.kernel.org

The caller of rtl8169_tso_csum_v2() frees the skb if false is returned.
eth_skb_pad() internally frees the skb on error what would result in a
double free. Therefore use __skb_put_padto() directly and instruct it
to not free the skb on error.

Fixes: 	25e992a4603c ("r8169: rename r8169.c to r8169_main.c")
Reported-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
The Fixes tag refers to the change from which on the patch applies.
However it will apply with a little fuzz only on versions up to 5.9.
---
 drivers/net/ethernet/realtek/r8169_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 07d197141..c5d5c1cfc 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -4134,7 +4134,8 @@ static bool rtl8169_tso_csum_v2(struct rtl8169_private *tp,
 		opts[1] |= transport_offset << TCPHO_SHIFT;
 	} else {
 		if (unlikely(skb->len < ETH_ZLEN && rtl_test_hw_pad_bug(tp)))
-			return !eth_skb_pad(skb);
+			/* eth_skb_pad would free the skb on error */
+			return !__skb_put_padto(skb, ETH_ZLEN, false);
 	}
 
 	return true;
-- 
2.29.2


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

* Re: [PATCH net] r8169: fix potential skb double free in an error path
  2020-11-05 14:28 [PATCH net] r8169: fix potential skb double free in an error path Heiner Kallweit
@ 2020-11-07 20:13 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2020-11-07 20:13 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: David Miller, Realtek linux nic maintainers,
	netdev@vger.kernel.org

On Thu, 5 Nov 2020 15:28:42 +0100 Heiner Kallweit wrote:
> The caller of rtl8169_tso_csum_v2() frees the skb if false is returned.
> eth_skb_pad() internally frees the skb on error what would result in a
> double free. Therefore use __skb_put_padto() directly and instruct it
> to not free the skb on error.
> 
> Fixes: 25e992a4603c ("r8169: rename r8169.c to r8169_main.c")
> Reported-by: Jakub Kicinski <kuba@kernel.org>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> The Fixes tag refers to the change from which on the patch applies.
> However it will apply with a little fuzz only on versions up to 5.9.

I think we've been over this, please provide real fixes tags, pointing
to where bugs were introduced. I swapped the tag for:

Fixes: b423e9ae49d7 ("r8169: fix offloaded tx checksum for small packets.")

and applied, thanks.

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

end of thread, other threads:[~2020-11-07 20:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-05 14:28 [PATCH net] r8169: fix potential skb double free in an error path Heiner Kallweit
2020-11-07 20:13 ` Jakub Kicinski

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).