Skip to content

Commit 90e5d0d

Browse files
kraigatgoogdavem330
authored andcommitted
soreuseport: Fix TCP listener hash collision
I forgot to include a check for listener port equality when deciding if two sockets should belong to the same reuseport group. This was not caught previously because it's only necessary when two listening sockets for the same user happen to hash to the same listener bucket. The same error does not exist in the UDP path. Fixes: c125e80("soreuseport: fast reuseport TCP socket selection") Signed-off-by: Craig Gallek <kraig@google.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 018f825 commit 90e5d0d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/ipv4/inet_hashtables.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ static int inet_reuseport_add_sock(struct sock *sk,
470470
const struct sock *sk2,
471471
bool match_wildcard))
472472
{
473+
struct inet_bind_bucket *tb = inet_csk(sk)->icsk_bind_hash;
473474
struct sock *sk2;
474475
struct hlist_nulls_node *node;
475476
kuid_t uid = sock_i_uid(sk);
@@ -479,6 +480,7 @@ static int inet_reuseport_add_sock(struct sock *sk,
479480
sk2->sk_family == sk->sk_family &&
480481
ipv6_only_sock(sk2) == ipv6_only_sock(sk) &&
481482
sk2->sk_bound_dev_if == sk->sk_bound_dev_if &&
483+
inet_csk(sk2)->icsk_bind_hash == tb &&
482484
sk2->sk_reuseport && uid_eq(uid, sock_i_uid(sk2)) &&
483485
saddr_same(sk, sk2, false))
484486
return reuseport_add_sock(sk, sk2);

0 commit comments

Comments
 (0)