Skip to content

Commit 4a0ec2a

Browse files
edumazetkuba-moo
authored andcommitted
ipv6: switch inet6_addr_hash() to less predictable hash
In commit 3f27fb2 ("ipv6: addrconf: add per netns perturbation in inet6_addr_hash()"), I added net_hash_mix() in inet6_addr_hash() to get better hash dispersion, at a time all netns were sharing the hash table. Since then, commit 21a216a ("ipv6/addrconf: allocate a per netns hash table") made the hash table per netns. We could remove the net_hash_mix() from inet6_addr_hash(), but there is still an issue with ipv6_addr_hash(). It is highly predictable and a malicious user can easily create thousands of IPv6 addresses all stored in the same hash bucket. Switch to __ipv6_addr_jhash(). We could use a dedicated secret, or reuse net_hash_mix() as I did in this patch. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: David Ahern <dsahern@kernel.org> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Link: https://patch.msgid.link/20241008120101.734521-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 2518b11 commit 4a0ec2a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/ipv6/addrconf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp)
10161016

10171017
static u32 inet6_addr_hash(const struct net *net, const struct in6_addr *addr)
10181018
{
1019-
u32 val = ipv6_addr_hash(addr) ^ net_hash_mix(net);
1019+
u32 val = __ipv6_addr_jhash(addr, net_hash_mix(net));
10201020

10211021
return hash_32(val, IN6_ADDR_HSIZE_SHIFT);
10221022
}

0 commit comments

Comments
 (0)