tcp_rtt_tsopt_us() returns the timestamp clock minus TSecr as an RTT sample, and accepts up to 2,147 s. If TSecr echoes an old timestamp, the sample is the age of that timestamp, not an RTT. tcp_ack_update_rtt() takes this sample for an ACK of retransmitted data. tcp_rtt_estimator() clamps it to 120 s. The congestion control gets the sample unclamped, in rs->rtt_us. tcp_rcv_rtt_measure_ts() takes the same sample for the RTT estimate of the receive side. The fix used here is to reject a sample from TSecr above 120 s, for both callers of tcp_rtt_tsopt_us(). An ACK of retransmitted data whose TSecr is more than 120 s old now gives no RTT sample. So it no longer resets the backoff, as on a connection without timestamps. Found by LLM code inspection, and confirmed with LLM generated reproducers on an unmodified kernel. Fixed by LLM, and tested with the reproducers and existing kernel selftests. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Chris Mason --- Notes: v1->v2: no code change, the part on sample << 3 moved to patch 4 net/ipv4/tcp_input.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index e796497b84be..69e038b9389a 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -901,15 +901,16 @@ static inline void tcp_rcv_rtt_measure(struct tcp_sock *tp) tp->rcv_rtt_est.time = tp->tcp_mstamp; } +/* A sample from TSecr above TCP_RTT_MAX_US is bogus, not large. */ static s32 tcp_rtt_tsopt_us(const struct tcp_sock *tp, u32 min_delta) { u32 delta, delta_us; delta = tcp_time_stamp_ts(tp) - tp->rx_opt.rcv_tsecr; if (tp->tcp_usec_ts) - return delta; + return delta <= TCP_RTT_MAX_US ? delta : -1; - if (likely(delta < INT_MAX / (USEC_PER_SEC / TCP_TS_HZ))) { + if (likely(delta <= TCP_RTT_MAX_US / (USEC_PER_SEC / TCP_TS_HZ))) { if (!delta) delta = min_delta; delta_us = delta * (USEC_PER_SEC / TCP_TS_HZ); -- 2.55.0