From: Joe Perches <joe@perches.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: David Miller <davem@davemloft.net>,
netdev <netdev@vger.kernel.org>,
Neal Cardwell <ncardwell@google.com>,
Yuchung Cheng <ycheng@google.com>
Subject: Re: [PATCH net-next] tcp: avoid possible arithmetic overflows
Date: Sat, 20 Sep 2014 11:01:11 -0700 [thread overview]
Message-ID: <1411236071.8612.6.camel@joe-AO725> (raw)
In-Reply-To: <1411233550.26859.76.camel@edumazet-glaptop2.roam.corp.google.com>
On Sat, 2014-09-20 at 10:19 -0700, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> icsk_rto is an 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
Maybe better to use a helper function for this?
something like:
static inline u64 icsk_rto_backoff(const struct inet_connection_sock *icsk)
{
u64 when = (u64)icsk->icsk_rto;
return when << icsk->icsk_backoff;
}
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
[]
> @@ -3208,9 +3208,12 @@ static void tcp_ack_probe(struct sock *sk)
> * This function is not for random using!
> */
> } else {
> + unsigned long when;
> +
> + when = min((u64)icsk->icsk_rto << icsk->icsk_backoff,
> + (u64)TCP_RTO_MAX);
Maybe:
u32 when = (u32)min_t(u64, icsk_rto_backoff(icsk), TCP_RTO_MAX);
next prev parent reply other threads:[~2014-09-20 18:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-20 17:19 [PATCH net-next] tcp: avoid possible arithmetic overflows Eric Dumazet
2014-09-20 18:01 ` Joe Perches [this message]
2014-09-20 19:46 ` Yuchung Cheng
2014-09-20 19:55 ` Eric Dumazet
2014-09-20 20:19 ` Joe Perches
2014-09-21 0:29 ` [PATCH v2 " Eric Dumazet
2014-09-21 17:46 ` Yuchung Cheng
2014-09-22 12:42 ` Eric Dumazet
2014-09-22 20:19 ` [PATCH v3 " Eric Dumazet
2014-09-22 20:27 ` David Miller
2014-09-22 20:28 ` Eric Dumazet
2014-09-22 3:56 ` [PATCH v2 " Joe Perches
2014-09-22 11:13 ` [PATCH " David Laight
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1411236071.8612.6.camel@joe-AO725 \
--to=joe@perches.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=ycheng@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).