]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
tcp: use different parts of the port_offset for index and offset
authorWilly Tarreau <w@1wt.eu>
Mon, 2 May 2022 08:46:09 +0000 (10:46 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 10 Aug 2022 07:22:13 +0000 (09:22 +0200)
BugLink: https://bugs.launchpad.net/bugs/1980278
[ Upstream commit 9e9b70ae923baf2b5e8a0ea4fd0c8451801ac526 ]

Amit Klein suggests that we use different parts of port_offset for the
table's index and the port offset so that there is no direct relation
between them.

Cc: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: Moshe Kol <moshe.kol@mail.huji.ac.il>
Cc: Yossi Gilad <yossi.gilad@mail.huji.ac.il>
Cc: Amit Klein <aksecurity@gmail.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
net/ipv4/inet_hashtables.c

index 606a4220ebb9d4696ce737636b1f7a0fd19c102b..81a33af8393db48d58d008a8e96eed7b757363ac 100644 (file)
@@ -777,7 +777,7 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,
        net_get_random_once(table_perturb, sizeof(table_perturb));
        index = hash_32(port_offset, INET_TABLE_PERTURB_SHIFT);
 
-       offset = READ_ONCE(table_perturb[index]) + port_offset;
+       offset = READ_ONCE(table_perturb[index]) + (port_offset >> 32);
        offset %= remaining;
 
        /* In first pass we try ports of @low parity.