tcp: change source port randomizarion at connect() time
authorEric Dumazet <edumazet@google.com>
Tue, 9 Feb 2021 19:20:27 +0000 (11:20 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 11 Feb 2021 21:13:04 +0000 (13:13 -0800)
commit190cc82489f46f9d88e73c81a47e14f80a791e1a
tree1a380ef01a6dd94561dd62da33827c2b43c88d79
parent1edb5cbf49a7464a575966ad6f48b3876fb64f63
tcp: change source port randomizarion at connect() time

RFC 6056 (Recommendations for Transport-Protocol Port Randomization)
provides good summary of why source selection needs extra care.

David Dworken reminded us that linux implements Algorithm 3
as described in RFC 6056 3.3.3

Quoting David :
   In the context of the web, this creates an interesting info leak where
   websites can count how many TCP connections a user's computer is
   establishing over time. For example, this allows a website to count
   exactly how many subresources a third party website loaded.
   This also allows:
   - Distinguishing between different users behind a VPN based on
       distinct source port ranges.
   - Tracking users over time across multiple networks.
   - Covert communication channels between different browsers/browser
       profiles running on the same computer
   - Tracking what applications are running on a computer based on
       the pattern of how fast source ports are getting incremented.

Section 3.3.4 describes an enhancement, that reduces
attackers ability to use the basic information currently
stored into the shared 'u32 hint'.

This change also decreases collision rate when
multiple applications need to connect() to
different destinations.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: David Dworken <ddworken@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/inet_hashtables.c