Skip to content

Commit b2b7af8

Browse files
yuchungchengdavem330
authored andcommitted
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. Reported-by: Rafael Tinoco <[email protected]> Signed-off-by: Yuchung Cheng <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: Neal Cardwell <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4172754 commit b2b7af8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

net/ipv4/tcp_output.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2497,15 +2497,18 @@ void tcp_send_loss_probe(struct sock *sk)
24972497
goto rearm_timer;
24982498
}
24992499
skb = skb_rb_last(&sk->tcp_rtx_queue);
2500+
if (unlikely(!skb)) {
2501+
WARN_ONCE(tp->packets_out,
2502+
"invalid inflight: %u state %u cwnd %u mss %d\n",
2503+
tp->packets_out, sk->sk_state, tp->snd_cwnd, mss);
2504+
inet_csk(sk)->icsk_pending = 0;
2505+
return;
2506+
}
25002507

25012508
/* At most one outstanding TLP retransmission. */
25022509
if (tp->tlp_high_seq)
25032510
goto rearm_timer;
25042511

2505-
/* Retransmit last segment. */
2506-
if (WARN_ON(!skb))
2507-
goto rearm_timer;
2508-
25092512
if (skb_still_in_host_queue(sk, skb))
25102513
goto rearm_timer;
25112514

0 commit comments

Comments
 (0)