It looks like tcp_seq_init() is supposed to advance the sequence number
by one every 32ns. However we only right shift the ns part of the timespec
not the seconds part, meaning that we'll advance by an extra 32 steps on
each second.
I don't know if that's exploitable in any way, but it doesn't appear to be
the intent, nor what RFC 6528 suggests.
Signed-off-by: David Gibson
---
tcp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tcp.c b/tcp.c
index 59e03ff..941fafb 100644
--- a/tcp.c
+++ b/tcp.c
@@ -2027,8 +2027,8 @@ static void tcp_seq_init(const struct ctx *c, struct tcp_conn *conn,
seq = siphash_36b((uint8_t *)&in, c->tcp.hash_secret);
- ns = now->tv_sec * 1E9;
- ns += now->tv_nsec >> 5; /* 32ns ticks, overflows 32 bits every 137s */
+ /* 32ns ticks, overflows 32 bits every 137s */
+ ns = (now->tv_sec * 1E9 + now->tv_nsec) >> 5;
conn->seq_to_tap = seq + ns;
}
--
2.38.1