netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 net] soreuseport: Fix TCP listener hash collision
@ 2016-04-28 23:24 Craig Gallek
  2016-04-28 23:46 ` Eric Dumazet
  2016-05-01 23:38 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Craig Gallek @ 2016-04-28 23:24 UTC (permalink / raw)
  To: davem; +Cc: netdev

From: Craig Gallek <kraig@google.com>

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: c125e80b8868("soreuseport: fast reuseport TCP socket selection")
Signed-off-by: Craig Gallek <kraig@google.com>
---
v3 Changes
  - Eric pointed out that the net namespace check isn't necessary when
    comparing bucket pointers.  They can not be equal across namespaces.
v2 Changes
  - Suggestions from Eric Dumazet to include network namespace equality
    check and to avoid a dreference by simply checking inet_bind_bucket
    pointer equality.
---
 net/ipv4/inet_hashtables.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index bc68eced0105..0d9e9d7bb029 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -470,6 +470,7 @@ static int inet_reuseport_add_sock(struct sock *sk,
 						     const struct sock *sk2,
 						     bool match_wildcard))
 {
+	struct inet_bind_bucket *tb = inet_csk(sk)->icsk_bind_hash;
 	struct sock *sk2;
 	struct hlist_nulls_node *node;
 	kuid_t uid = sock_i_uid(sk);
@@ -479,6 +480,7 @@ static int inet_reuseport_add_sock(struct sock *sk,
 		    sk2->sk_family == sk->sk_family &&
 		    ipv6_only_sock(sk2) == ipv6_only_sock(sk) &&
 		    sk2->sk_bound_dev_if == sk->sk_bound_dev_if &&
+		    inet_csk(sk2)->icsk_bind_hash == tb &&
 		    sk2->sk_reuseport && uid_eq(uid, sock_i_uid(sk2)) &&
 		    saddr_same(sk, sk2, false))
 			return reuseport_add_sock(sk, sk2);
-- 
2.8.0.rc3.226.g39d4020

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 net] soreuseport: Fix TCP listener hash collision
  2016-04-28 23:24 [PATCH v3 net] soreuseport: Fix TCP listener hash collision Craig Gallek
@ 2016-04-28 23:46 ` Eric Dumazet
  2016-05-01 23:38 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2016-04-28 23:46 UTC (permalink / raw)
  To: Craig Gallek; +Cc: davem, netdev

On Thu, 2016-04-28 at 19:24 -0400, Craig Gallek wrote:
> From: Craig Gallek <kraig@google.com>
> 
> 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: c125e80b8868("soreuseport: fast reuseport TCP socket selection")
> Signed-off-by: Craig Gallek <kraig@google.com>
> ---

Thanks Craig

Acked-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 net] soreuseport: Fix TCP listener hash collision
  2016-04-28 23:24 [PATCH v3 net] soreuseport: Fix TCP listener hash collision Craig Gallek
  2016-04-28 23:46 ` Eric Dumazet
@ 2016-05-01 23:38 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-05-01 23:38 UTC (permalink / raw)
  To: kraigatgoog; +Cc: netdev

From: Craig Gallek <kraigatgoog@gmail.com>
Date: Thu, 28 Apr 2016 19:24:32 -0400

> From: Craig Gallek <kraig@google.com>
> 
> 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: c125e80b8868("soreuseport: fast reuseport TCP socket selection")
> Signed-off-by: Craig Gallek <kraig@google.com>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-05-01 23:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-28 23:24 [PATCH v3 net] soreuseport: Fix TCP listener hash collision Craig Gallek
2016-04-28 23:46 ` Eric Dumazet
2016-05-01 23:38 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).