From: Eric Dumazet <hidden> Date: 2021-08-25 23:17:36
From: Eric Dumazet <edumazet@google.com>
A group of security researchers brought to our attention
the weakness of hash functions used in rt6_exception_hash()
and fnhe_hashfun()
I made two distinct patches to help backports, since IPv6
part was added in 4.15
Eric Dumazet (2):
ipv6: use siphash in rt6_exception_hash()
ipv4: use siphash instead of Jenkins in fnhe_hashfun()
net/ipv4/route.c | 12 ++++++------
net/ipv6/route.c | 20 ++++++++++++++------
2 files changed, 20 insertions(+), 12 deletions(-)
--
2.33.0.rc2.250.ged5fa647cd-goog
From: Eric Dumazet <hidden> Date: 2021-08-25 23:17:42
From: Eric Dumazet <edumazet@google.com>
A group of security researchers brought to our attention
the weakness of hash function used in fnhe_hashfun().
Lets use siphash instead of Jenkins Hash, to considerably
reduce security risks.
Also remove the inline keyword, this really is distracting.
Fixes: d546c621542d ("ipv4: harden fnhe_hashfun()")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Keyu Man <redacted>
Cc: Willy Tarreau <w@1wt.eu>
---
net/ipv4/route.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
From: Eric Dumazet <hidden> Date: 2021-08-25 23:17:42
From: Eric Dumazet <edumazet@google.com>
A group of security researchers brought to our attention
the weakness of hash function used in rt6_exception_hash()
Lets use siphash instead of Jenkins Hash, to considerably
reduce security risks.
Following patch deals with IPv4.
Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Keyu Man <redacted>
Cc: Wei Wang <redacted>
Cc: Martin KaFai Lau <redacted>
---
net/ipv6/route.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
@@ -1484,17 +1485,24 @@ static void rt6_exception_remove_oldest(struct rt6_exception_bucket *bucket)staticu32rt6_exception_hash(conststructin6_addr*dst,conststructin6_addr*src){-staticu32seed__read_mostly;-u32val;+staticsiphash_key_trt6_exception_key__read_mostly;+struct{+structin6_addrdst;+structin6_addrsrc;+}__aligned(SIPHASH_ALIGNMENT)combined={+.dst=*dst,+};+u64val;-net_get_random_once(&seed,sizeof(seed));-val=jhash2((constu32*)dst,sizeof(*dst)/sizeof(u32),seed);+net_get_random_once(&rt6_exception_key,sizeof(rt6_exception_key));#ifdef CONFIG_IPV6_SUBTREESif(src)-val=jhash2((constu32*)src,sizeof(*src)/sizeof(u32),val);+combined.src=*src;#endif-returnhash_32(val,FIB6_EXCEPTION_BUCKET_SIZE_SHIFT);+val=siphash(&combined,sizeof(combined),&rt6_exception_key);++returnhash_64(val,FIB6_EXCEPTION_BUCKET_SIZE_SHIFT);}/* Helper function to find the cached rt in the hash table
On Wed, Aug 25, 2021 at 4:17 PM Eric Dumazet [off-list ref] wrote:
From: Eric Dumazet <edumazet@google.com>
A group of security researchers brought to our attention
the weakness of hash function used in rt6_exception_hash()
Lets use siphash instead of Jenkins Hash, to considerably
reduce security risks.
Following patch deals with IPv4.
Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Keyu Man <redacted>
Cc: Wei Wang <redacted>
Cc: Martin KaFai Lau <redacted>
@@ -1484,17 +1485,24 @@ static void rt6_exception_remove_oldest(struct rt6_exception_bucket *bucket)staticu32rt6_exception_hash(conststructin6_addr*dst,conststructin6_addr*src){-staticu32seed__read_mostly;-u32val;+staticsiphash_key_trt6_exception_key__read_mostly;+struct{+structin6_addrdst;+structin6_addrsrc;+}__aligned(SIPHASH_ALIGNMENT)combined={+.dst=*dst,+};+u64val;-net_get_random_once(&seed,sizeof(seed));-val=jhash2((constu32*)dst,sizeof(*dst)/sizeof(u32),seed);+net_get_random_once(&rt6_exception_key,sizeof(rt6_exception_key));#ifdef CONFIG_IPV6_SUBTREESif(src)-val=jhash2((constu32*)src,sizeof(*src)/sizeof(u32),val);+combined.src=*src;#endif-returnhash_32(val,FIB6_EXCEPTION_BUCKET_SIZE_SHIFT);+val=siphash(&combined,sizeof(combined),&rt6_exception_key);++returnhash_64(val,FIB6_EXCEPTION_BUCKET_SIZE_SHIFT);}/* Helper function to find the cached rt in the hash table--
Hello:
This series was applied to netdev/net.git (refs/heads/master):
On Wed, 25 Aug 2021 16:17:27 -0700 you wrote:
From: Eric Dumazet <edumazet@google.com>
A group of security researchers brought to our attention
the weakness of hash functions used in rt6_exception_hash()
and fnhe_hashfun()
I made two distinct patches to help backports, since IPv6
part was added in 4.15
[...]