Skip to content

Commit 36534d3

Browse files
edumazetkuba-moo
authored andcommitted
tcp: use signed arithmetic in tcp_rtx_probe0_timed_out()
Due to timer wheel implementation, a timer will usually fire after its schedule. For instance, for HZ=1000, a timeout between 512ms and 4s has a granularity of 64ms. For this range of values, the extra delay could be up to 63ms. For TCP, this means that tp->rcv_tstamp may be after inet_csk(sk)->icsk_timeout whenever the timer interrupt finally triggers, if one packet came during the extra delay. We need to make sure tcp_rtx_probe0_timed_out() handles this case. Fixes: e89688e ("net: tcp: fix unexcepted socket die when snd_wnd is 0") Signed-off-by: Eric Dumazet <[email protected]> Cc: Menglong Dong <[email protected]> Acked-by: Neal Cardwell <[email protected]> Reviewed-by: Jason Xing <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 70b3c88 commit 36534d3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

net/ipv4/tcp_timer.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,12 @@ static bool tcp_rtx_probe0_timed_out(const struct sock *sk,
485485
{
486486
const struct tcp_sock *tp = tcp_sk(sk);
487487
const int timeout = TCP_RTO_MAX * 2;
488-
u32 rcv_delta;
488+
s32 rcv_delta;
489489

490+
/* Note: timer interrupt might have been delayed by at least one jiffy,
491+
* and tp->rcv_tstamp might very well have been written recently.
492+
* rcv_delta can thus be negative.
493+
*/
490494
rcv_delta = inet_csk(sk)->icsk_timeout - tp->rcv_tstamp;
491495
if (rcv_delta <= timeout)
492496
return false;

0 commit comments

Comments
 (0)