Skip to content

Commit a904a06

Browse files
edumazetdavem330
authored andcommitted
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: 1da177e ("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>
1 parent c8c2cd8 commit a904a06

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

drivers/crypto/chelsio/chtls/chtls_cm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ static void make_established(struct sock *sk, u32 snd_isn, unsigned int opt)
12971297
tp->write_seq = snd_isn;
12981298
tp->snd_nxt = snd_isn;
12991299
tp->snd_una = snd_isn;
1300-
inet_sk(sk)->inet_id = tp->write_seq ^ jiffies;
1300+
inet_sk(sk)->inet_id = prandom_u32();
13011301
assign_rxopt(sk, opt);
13021302

13031303
if (tp->rcv_wnd > (RCV_BUFSIZ_M << 10))

net/dccp/ipv4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
117117
inet->inet_daddr,
118118
inet->inet_sport,
119119
inet->inet_dport);
120-
inet->inet_id = dp->dccps_iss ^ jiffies;
120+
inet->inet_id = prandom_u32();
121121

122122
err = dccp_connect(sk);
123123
rt = NULL;

net/ipv4/datagram.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ int __ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
7373
reuseport_has_conns(sk, true);
7474
sk->sk_state = TCP_ESTABLISHED;
7575
sk_set_txhash(sk);
76-
inet->inet_id = jiffies;
76+
inet->inet_id = prandom_u32();
7777

7878
sk_dst_set(sk, &rt->dst);
7979
err = 0;

net/ipv4/tcp_ipv4.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
303303
inet->inet_daddr);
304304
}
305305

306-
inet->inet_id = tp->write_seq ^ jiffies;
306+
inet->inet_id = prandom_u32();
307307

308308
if (tcp_fastopen_defer_connect(sk, &err))
309309
return err;
@@ -1450,7 +1450,7 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
14501450
inet_csk(newsk)->icsk_ext_hdr_len = 0;
14511451
if (inet_opt)
14521452
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();
14541454

14551455
if (!dst) {
14561456
dst = inet_csk_route_child_sock(sk, newsk, req);

net/sctp/socket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9306,7 +9306,7 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk,
93069306
newinet->inet_rcv_saddr = inet->inet_rcv_saddr;
93079307
newinet->inet_dport = htons(asoc->peer.port);
93089308
newinet->pmtudisc = inet->pmtudisc;
9309-
newinet->inet_id = asoc->next_tsn ^ jiffies;
9309+
newinet->inet_id = prandom_u32();
93109310

93119311
newinet->uc_ttl = inet->uc_ttl;
93129312
newinet->mc_loop = 1;

0 commit comments

Comments
 (0)