mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-12-02 00:40:59 -05:00
tcp: resalt the secret every 10 seconds
[ Upstream commit 4dfa9b438ee34caca4e6a4e5e961641807367f6f ] In order to limit the ability for an observer to recognize the source ports sequence used to contact a set of destinations, we should periodically shuffle the secret. 10 seconds looks effective enough without causing particular issues. Cc: Moshe Kol <[email protected]> Cc: Yossi Gilad <[email protected]> Cc: Amit Klein <[email protected]> Cc: Jason A. Donenfeld <[email protected]> Tested-by: Willy Tarreau <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
This commit is contained in:
parent
39c26fe93c
commit
6e34ee5b5b
1 changed files with 9 additions and 3 deletions
|
|
@ -23,6 +23,8 @@
|
|||
static siphash_key_t net_secret __read_mostly;
|
||||
static siphash_key_t ts_secret __read_mostly;
|
||||
|
||||
#define EPHEMERAL_PORT_SHUFFLE_PERIOD (10 * HZ)
|
||||
|
||||
static __always_inline void net_secret_init(void)
|
||||
{
|
||||
net_get_random_once(&net_secret, sizeof(net_secret));
|
||||
|
|
@ -101,11 +103,13 @@ u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
|
|||
const struct {
|
||||
struct in6_addr saddr;
|
||||
struct in6_addr daddr;
|
||||
unsigned int timeseed;
|
||||
__be16 dport;
|
||||
} __aligned(SIPHASH_ALIGNMENT) combined = {
|
||||
.saddr = *(struct in6_addr *)saddr,
|
||||
.daddr = *(struct in6_addr *)daddr,
|
||||
.dport = dport
|
||||
.timeseed = jiffies / EPHEMERAL_PORT_SHUFFLE_PERIOD,
|
||||
.dport = dport,
|
||||
};
|
||||
net_secret_init();
|
||||
return siphash(&combined, offsetofend(typeof(combined), dport),
|
||||
|
|
@ -146,8 +150,10 @@ EXPORT_SYMBOL_GPL(secure_tcp_seq);
|
|||
u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport)
|
||||
{
|
||||
net_secret_init();
|
||||
return siphash_3u32((__force u32)saddr, (__force u32)daddr,
|
||||
(__force u16)dport, &net_secret);
|
||||
return siphash_4u32((__force u32)saddr, (__force u32)daddr,
|
||||
(__force u16)dport,
|
||||
jiffies / EPHEMERAL_PORT_SHUFFLE_PERIOD,
|
||||
&net_secret);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(secure_ipv4_port_ephemeral);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue