diff options
author | Eric Dumazet <edumazet@google.com> | 2023-10-20 14:57:37 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-10-23 10:35:00 +0200 |
commit | 73ed8e03388d16c12fc577e5c700b58a29045a15 (patch) | |
tree | f241b24e8f1585042fd39672ff920994da3e8b37 /include/net/tcp.h | |
parent | chtls: fix tp->rcv_tstamp initialization (diff) | |
download | linux-73ed8e03388d16c12fc577e5c700b58a29045a15.tar.xz linux-73ed8e03388d16c12fc577e5c700b58a29045a15.zip |
tcp: fix cookie_init_timestamp() overflows
cookie_init_timestamp() is supposed to return a 64bit timestamp
suitable for both TSval determination and setting of skb->tstamp.
Unfortunately it uses 32bit fields and overflows after
2^32 * 10^6 nsec (~49 days) of uptime.
Generated TSval are still correct, but skb->tstamp might be set
far away in the past, potentially confusing other layers.
tcp_ns_to_ts() is changed to return a full 64bit value,
ts and ts_now variables are changed to u64 type,
and TSMASK is removed in favor of shifts operations.
While we are at it, change this sequence:
ts >>= TSBITS;
ts--;
ts <<= TSBITS;
ts |= options;
to:
ts -= (1UL << TSBITS);
Fixes: 9a568de4818d ("tcp: switch TCP TS option (RFC 7323) to 1ms clock")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r-- | include/net/tcp.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index bad304d173a5..d47a57a47b50 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -805,7 +805,7 @@ static inline u32 tcp_time_stamp(const struct tcp_sock *tp) } /* Convert a nsec timestamp into TCP TSval timestamp (ms based currently) */ -static inline u32 tcp_ns_to_ts(u64 ns) +static inline u64 tcp_ns_to_ts(u64 ns) { return div_u64(ns, NSEC_PER_SEC / TCP_TS_HZ); } |