Skip to contentSkip to conversation

tcp: fix NULL ref in tail loss probe

PATCH Applied Yuchung Cheng 2 participants 2 messages Dec 5, 2018 – Dec 6, 2018

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

PATCH 1/1 tcp: fix NULL ref in tail loss probe

TCP loss probe timer may fire when the retranmission queue is empty but has a non-zero tp->packets_out counter. tcp_send_loss_probe will call tcp_rearm_rto which triggers NULL pointer reference by fetching the retranmission queue head in its sub-routines.

Add a more detailed warning to help catch the root cause of the inflight accounting inconsistency.

---
 net/ipv4/tcp_output.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
net/ipv4/tcp_output.c +7 -4
index 68b5326f7321..9a1101095298 100644
@@ -2494,15 +2494,18 @@ void tcp_send_loss_probe(struct sock *sk)
 		goto rearm_timer;
 	}
 	skb = skb_rb_last(&sk->tcp_rtx_queue);
+	if (unlikely(!skb)) {
+		WARN_ONCE(tp->packets_out,
+			  "invalid inflight: %u state %u cwnd %u mss %d\n",
+			  tp->packets_out, sk->sk_state, tp->snd_cwnd, mss);
+		inet_csk(sk)->icsk_pending = 0;
+		return;
+	}
 
 	/* At most one outstanding TLP retransmission. */
 	if (tp->tlp_high_seq)
 		goto rearm_timer;
 
-	/* Retransmit last segment. */
-	if (WARN_ON(!skb))
-		goto rearm_timer;
-
 	if (skb_still_in_host_queue(sk, skb))
 		goto rearm_timer;
 
Signature · 1 line
2.20.0.rc1.387.gf8505762e3-goog
maintainer Applied
#1 lore raw

From: Yuchung Cheng <[email protected]>
Date: Wed, 5 Dec 2018 14:38:38 -0800

Quoted 5 lines

TCP loss probe timer may fire when the retranmission queue is empty but has a non-zero tp->packets_out counter. tcp_send_loss_probe will call tcp_rearm_rto which triggers NULL pointer reference by fetching the retranmission queue head in its sub-routines.

Quoted 7 lines

Add a more detailed warning to help catch the root cause of the inflight accounting inconsistency.

Applied, thanks for working to diagnose this so quickly.