Skip to content

Commit 0c69903

Browse files
ahacigu-linuxgregkh
authored andcommitted
tcp: make probe0 timer handle expired user timeout
[ Upstream commit 2b9f6f7 ] tcp_clamp_probe0_to_user_timeout() computes remaining time in jiffies using subtraction with an unsigned lvalue. If elapsed probing time exceeds the configured TCP_USER_TIMEOUT, the underflow yields a large value. This ends up re-arming the probe timer for a full backoff interval instead of expiring immediately, delaying connection teardown beyond the configured timeout. Fix this by preventing underflow so user-set timeout expiration is handled correctly without extending the probe timer. Fixes: 344db93 ("tcp: make TCP_USER_TIMEOUT accurate for zero window probes") Link: https://lore.kernel.org/r/20260414013634.43997-1-ahacigu.linux@gmail.com Signed-off-by: Altan Hacigumus <ahacigu.linux@gmail.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20260424014639.54110-1-ahacigu.linux@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 0084712 commit 0c69903

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

net/ipv4/tcp_timer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ static u32 tcp_clamp_rto_to_user_timeout(const struct sock *sk)
4949
u32 tcp_clamp_probe0_to_user_timeout(const struct sock *sk, u32 when)
5050
{
5151
const struct inet_connection_sock *icsk = inet_csk(sk);
52-
u32 remaining, user_timeout;
52+
u32 user_timeout;
53+
s32 remaining;
5354
s32 elapsed;
5455

5556
user_timeout = READ_ONCE(icsk->icsk_user_timeout);
@@ -60,7 +61,7 @@ u32 tcp_clamp_probe0_to_user_timeout(const struct sock *sk, u32 when)
6061
if (unlikely(elapsed < 0))
6162
elapsed = 0;
6263
remaining = msecs_to_jiffies(user_timeout) - elapsed;
63-
remaining = max_t(u32, remaining, TCP_TIMEOUT_MIN);
64+
remaining = max_t(int, remaining, TCP_TIMEOUT_MIN);
6465

6566
return min_t(u32, remaining, when);
6667
}

0 commit comments

Comments
 (0)