Skip to contentSkip to conversation

tcp: also NULL skb->dev when copy was needed

PATCH In review Florian Westphal 3 participants 3 messages Mar 20, 2020 – Mar 21, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcp: also NULL skb->dev when copy was needed

In rare cases retransmit logic will make a full skb copy, which will not trigger the zeroing added in recent change
b738a185beaa ("tcp: ensure skb->dev is NULL before leaving TCP stack").

Cc Eric Dumazet <[email protected]>
Fixes 75c119afe14f ("tcp: implement rb-tree based retransmit queue")
Fixes 28f8bfd1ac94 ("netfilter: Support iif matches in POSTROUTING")
---
 net/ipv4/tcp_output.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
net/ipv4/tcp_output.c +6 -2
index e8cf8fde3d37..2f45cde168c4 100644
@@ -3041,8 +3041,12 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs)
 
 		tcp_skb_tsorted_save(skb) {
 			nskb = __pskb_copy(skb, MAX_TCP_HEADER, GFP_ATOMIC);
-			err = nskb ? tcp_transmit_skb(sk, nskb, 0, GFP_ATOMIC) :
-				     -ENOBUFS;
+			if (nskb) {
+				nskb->dev = NULL;
+				err = tcp_transmit_skb(sk, nskb, 0, GFP_ATOMIC);
+			} else {
+				err = -ENOBUFS;
+			}
 		} tcp_skb_tsorted_restore(skb);
 
 		if (!err) {
Signature · 1 line
2.24.1
#1 lore raw
Quoted 9 lines · Florian Westphal

In rare cases retransmit logic will make a full skb copy, which will not trigger the zeroing added in recent change
b738a185beaa ("tcp: ensure skb->dev is NULL before leaving TCP stack").

Cc Eric Dumazet <[email protected]>
Fixes 75c119afe14f ("tcp: implement rb-tree based retransmit queue")
Fixes 28f8bfd1ac94 ("netfilter: Support iif matches in POSTROUTING")

---

Good catch, thanks Florian !

maintainer
#2 lore raw
In reply to Florian Westphal

From: Florian Westphal <[email protected]>
Date: Fri, 20 Mar 2020 16:52:02 +0100

Quoted 8 lines

In rare cases retransmit logic will make a full skb copy, which will not trigger the zeroing added in recent change
b738a185beaa ("tcp: ensure skb->dev is NULL before leaving TCP stack").

Cc Eric Dumazet <[email protected]>
Fixes 75c119afe14f ("tcp: implement rb-tree based retransmit queue")
Fixes 28f8bfd1ac94 ("netfilter: Support iif matches in POSTROUTING")

Applied and queued up for -stable.