ipv6: switch inet6_acaddr_hash() to less predictable hash
Subsystems (3)
PATCH 1/1 ipv6: switch inet6_acaddr_hash() to less predictable hash
commit 2384d02520ff ("net/ipv6: Add anycast addresses to a global hashtable") added inet6_acaddr_hash(), using ipv6_addr_hash() and net_hash_mix() to get hash spreading for typical users.
However ipv6_addr_hash() is highly predictable and a malicious user could abuse a specific hash bucket.
Switch to __ipv6_addr_jhash(). We could use a dedicated secret, or reuse net_hash_mix() as I did in this patch.
--- net/ipv6/anycast.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/ipv6/anycast.c +3 -2
@@ -49,9 +49,10 @@ static DEFINE_SPINLOCK(acaddr_hash_lock);static int ipv6_dev_ac_dec (struct net_device *dev,const struct in6_addr *addr); -static u32 inet6_acaddr_hash (struct net *net,const struct in6_addr *addr) +static u32 inet6_acaddr_hash (const struct net *net, +const struct in6_addr *addr) { -u32 val =ipv6_addr_hash (addr) ^net_hash_mix (net); +u32 val =__ipv6_addr_jhash (addr,net_hash_mix (net));return hash_32 (val,IN6_ADDR_HSIZE_SHIFT ); }
Signature · 1 line
2.47.0.rc0.187.ge670bccf7e-goog
Quoted 7 lines · Eric Dumazet
commit
2384d02520ff("net/ipv6: Add anycast addresses to a global hashtable") addedinet6_acaddr_hash(), usingipv6_addr_hash()andnet_hash_mix()to get hash spreading for typical users.However
ipv6_addr_hash()is highly predictable and a malicious user could abuse a specific hash bucket.
Quoted 8 lines
Switch to
__ipv6_addr_jhash(). We could use a dedicated secret, or reusenet_hash_mix()as I did in this patch.Signed-off-by Eric Dumazet <[email protected]>--- net/ipv6/anycast.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
From: Eric Dumazet <[email protected]>
Date: Tue, 8 Oct 2024 12:13:07 +0000
Quoted 11 lines
commit
2384d02520ff("net/ipv6: Add anycast addresses to a global hashtable") addedinet6_acaddr_hash(), usingipv6_addr_hash()andnet_hash_mix()to get hash spreading for typical users.However
ipv6_addr_hash()is highly predictable and a malicious user could abuse a specific hash bucket.Switch to
__ipv6_addr_jhash(). We could use a dedicated secret, or reusenet_hash_mix()as I did in this patch.Signed-off-by Eric Dumazet <[email protected]>
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Tue, 8 Oct 2024 12:13:07 +0000 you wrote:
commit
2384d02520ff("net/ipv6: Add anycast addresses to a global hashtable") addedinet6_acaddr_hash(), usingipv6_addr_hash()andnet_hash_mix()to get hash spreading for typical users.However
ipv6_addr_hash()is highly predictable and a malicious user could abuse a specific hash bucket.[...]
Here is the summary with links:
- [net-next] ipv6: switch inet6_acaddr_hash() to less predictable hash
https://git.kernel.org/netdev/net-next/c/4daf4dc275f1
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html