aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_timer.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2014-09-22 16:19:44 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-22 16:27:10 -0400
commitfcdd1cf4dd63aecf86c987d7f4ec7187be5c2fbc (patch)
tree9f74f24f8fe931ffac65805a30bf7e53de7e89b1 /net/ipv4/tcp_timer.c
parent35f7aa5309c048bb70e58571942795fa9411ce6a (diff)
tcp: avoid possible arithmetic overflows
icsk_rto is a 32bit field, and icsk_backoff can reach 15 by default, or more if some sysctl (eg tcp_retries2) are changed. Better use 64bit to perform icsk_rto << icsk_backoff operations As Joe Perches suggested, add a helper for this. Yuchung spotted the tcp_v4_err() case. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_timer.c')
-rw-r--r--net/ipv4/tcp_timer.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index a339e7ba05a4..b24360f6e293 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -180,7 +180,7 @@ static int tcp_write_timeout(struct sock *sk)
180 180
181 retry_until = sysctl_tcp_retries2; 181 retry_until = sysctl_tcp_retries2;
182 if (sock_flag(sk, SOCK_DEAD)) { 182 if (sock_flag(sk, SOCK_DEAD)) {
183 const int alive = (icsk->icsk_rto < TCP_RTO_MAX); 183 const int alive = icsk->icsk_rto < TCP_RTO_MAX;
184 184
185 retry_until = tcp_orphan_retries(sk, alive); 185 retry_until = tcp_orphan_retries(sk, alive);
186 do_reset = alive || 186 do_reset = alive ||
@@ -294,7 +294,7 @@ static void tcp_probe_timer(struct sock *sk)
294 max_probes = sysctl_tcp_retries2; 294 max_probes = sysctl_tcp_retries2;
295 295
296 if (sock_flag(sk, SOCK_DEAD)) { 296 if (sock_flag(sk, SOCK_DEAD)) {
297 const int alive = ((icsk->icsk_rto << icsk->icsk_backoff) < TCP_RTO_MAX); 297 const int alive = inet_csk_rto_backoff(icsk, TCP_RTO_MAX) < TCP_RTO_MAX;
298 298
299 max_probes = tcp_orphan_retries(sk, alive); 299 max_probes = tcp_orphan_retries(sk, alive);
300 300