Skip to contentSkip to conversation

r8169: fix potential skb double free in an error path

PATCH In review Heiner Kallweit 2 participants 2 messages Nov 5, 2020 – Nov 7, 2020

Subsystems (3)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

PATCH 1/1 r8169: fix potential skb double free in an error path

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

---
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(-)
drivers/net/ethernet/realtek/r8169_main.c +2 -1
index 07d197141..c5d5c1cfc 100644
@@ -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;
Signature · 1 line
2.29.2
maintainer
#1 lore raw
Quoted 11 lines · 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")

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