]> git.ipfire.org Git - thirdparty/linux.git/commit
ipv6: switch inet6_addr_hash() to less predictable hash
authorEric Dumazet <edumazet@google.com>
Tue, 8 Oct 2024 12:01:01 +0000 (12:01 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 10 Oct 2024 02:33:46 +0000 (19:33 -0700)
commit4a0ec2aa0704c8271fde33a0f7bb92d09c066c17
tree9b651c6011530441df853a934244d746da9d568d
parent2518b119639162251b6cc7195aec394930c1d867
ipv6: switch inet6_addr_hash() to less predictable hash

In commit 3f27fb23219e ("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 21a216a8fc63 ("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>
net/ipv6/addrconf.c