summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2019-11-01 13:32:19 -0400
committerDavid S. Miller <davem@davemloft.net>2019-11-01 17:57:52 -0400
commita904a0693c189691eeee64f6c6b188bd7dc244e9 (patch)
tree393398816e62514323b428a7141d1d1bcecd73fa /net
parentc8c2cd8102a7b399873b3d001193a5abef42ffb8 (diff)
inet: stop leaking jiffies on the wire
Historically linux tried to stick to RFC 791, 1122, 2003 for IPv4 ID field generation. RFC 6864 made clear that no matter how hard we try, we can not ensure unicity of IP ID within maximum lifetime for all datagrams with a given source address/destination address/protocol tuple. Linux uses a per socket inet generator (inet_id), initialized at connection startup with a XOR of 'jiffies' and other fields that appear clear on the wire. Thiemo Nagel pointed that this strategy is a privacy concern as this provides 16 bits of entropy to fingerprint devices. Let's switch to a random starting point, this is just as good as far as RFC 6864 is concerned and does not leak anything critical. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: Thiemo Nagel <tnagel@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/dccp/ipv4.c2
-rw-r--r--net/ipv4/datagram.c2
-rw-r--r--net/ipv4/tcp_ipv4.c4
-rw-r--r--net/sctp/socket.c2
4 files changed, 5 insertions, 5 deletions
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index d9b4200ed12d..0d8f782c25cc 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -117,7 +117,7 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
117 inet->inet_daddr, 117 inet->inet_daddr,
118 inet->inet_sport, 118 inet->inet_sport,
119 inet->inet_dport); 119 inet->inet_dport);
120 inet->inet_id = dp->dccps_iss ^ jiffies; 120 inet->inet_id = prandom_u32();
121 121
122 err = dccp_connect(sk); 122 err = dccp_connect(sk);
123 rt = NULL; 123 rt = NULL;
diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
index 9a0fe0c2fa02..4a8550c49202 100644
--- a/net/ipv4/datagram.c
+++ b/net/ipv4/datagram.c
@@ -73,7 +73,7 @@ int __ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
73 reuseport_has_conns(sk, true); 73 reuseport_has_conns(sk, true);
74 sk->sk_state = TCP_ESTABLISHED; 74 sk->sk_state = TCP_ESTABLISHED;
75 sk_set_txhash(sk); 75 sk_set_txhash(sk);
76 inet->inet_id = jiffies; 76 inet->inet_id = prandom_u32();
77 77
78 sk_dst_set(sk, &rt->dst); 78 sk_dst_set(sk, &rt->dst);
79 err = 0; 79 err = 0;
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index b74192695955..67b2dc7a1727 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -303,7 +303,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
303 inet->inet_daddr); 303 inet->inet_daddr);
304 } 304 }
305 305
306 inet->inet_id = tp->write_seq ^ jiffies; 306 inet->inet_id = prandom_u32();
307 307
308 if (tcp_fastopen_defer_connect(sk, &err)) 308 if (tcp_fastopen_defer_connect(sk, &err))
309 return err; 309 return err;
@@ -1450,7 +1450,7 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
1450 inet_csk(newsk)->icsk_ext_hdr_len = 0; 1450 inet_csk(newsk)->icsk_ext_hdr_len = 0;
1451 if (inet_opt) 1451 if (inet_opt)
1452 inet_csk(newsk)->icsk_ext_hdr_len = inet_opt->opt.optlen; 1452 inet_csk(newsk)->icsk_ext_hdr_len = inet_opt->opt.optlen;
1453 newinet->inet_id = newtp->write_seq ^ jiffies; 1453 newinet->inet_id = prandom_u32();
1454 1454
1455 if (!dst) { 1455 if (!dst) {
1456 dst = inet_csk_route_child_sock(sk, newsk, req); 1456 dst = inet_csk_route_child_sock(sk, newsk, req);
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index ca81e06df165..ffd3262b7a41 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -9306,7 +9306,7 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk,
9306 newinet->inet_rcv_saddr = inet->inet_rcv_saddr; 9306 newinet->inet_rcv_saddr = inet->inet_rcv_saddr;
9307 newinet->inet_dport = htons(asoc->peer.port); 9307 newinet->inet_dport = htons(asoc->peer.port);
9308 newinet->pmtudisc = inet->pmtudisc; 9308 newinet->pmtudisc = inet->pmtudisc;
9309 newinet->inet_id = asoc->next_tsn ^ jiffies; 9309 newinet->inet_id = prandom_u32();
9310 9310
9311 newinet->uc_ttl = inet->uc_ttl; 9311 newinet->uc_ttl = inet->uc_ttl;
9312 newinet->mc_loop = 1; 9312 newinet->mc_loop = 1;