sharkcz / rpms / kernel

Forked from rpms/kernel 6 years ago
Clone
49af9ed
From patchwork Mon Sep 18 16:28:57 2017
49af9ed
Content-Type: text/plain; charset="utf-8"
49af9ed
MIME-Version: 1.0
49af9ed
Content-Transfer-Encoding: 7bit
49af9ed
Subject: [3/3] inet: fix improper empty comparison
49af9ed
X-Patchwork-Submitter: Josef Bacik <josef@toxicpanda.com>
49af9ed
X-Patchwork-Id: 815029
49af9ed
X-Patchwork-Delegate: davem@davemloft.net
49af9ed
Message-Id: <1505752137-15522-4-git-send-email-jbacik@fb.com>
49af9ed
To: davem@davemloft.net, netdev@vger.kernel.org,
49af9ed
 linux-kernel@vger.kernel.org, crobinso@redhat.com,
49af9ed
 labbott@redhat.com, kernel-team@fb.com
49af9ed
Cc: Josef Bacik <jbacik@fb.com>, stable@vger.kernel.org
49af9ed
Date: Mon, 18 Sep 2017 12:28:57 -0400
49af9ed
From: josef@toxicpanda.com
49af9ed
List-Id: <netdev.vger.kernel.org>
49af9ed
49af9ed
From: Josef Bacik <jbacik@fb.com>
49af9ed
49af9ed
When doing my reuseport rework I screwed up and changed a
49af9ed
49af9ed
if (hlist_empty(&tb->owners))
49af9ed
49af9ed
to
49af9ed
49af9ed
if (!hlist_empty(&tb->owners))
49af9ed
49af9ed
This is obviously bad as all of the reuseport/reuse logic was reversed,
49af9ed
which caused weird problems like allowing an ipv4 bind conflict if we
49af9ed
opened an ipv4 only socket on a port followed by an ipv6 only socket on
49af9ed
the same port.
49af9ed
49af9ed
Cc: stable@vger.kernel.org
49af9ed
Fixes: b9470c27607b ("inet: kill smallest_size and smallest_port")
49af9ed
Reported-by: Cole Robinson <crobinso@redhat.com>
49af9ed
Signed-off-by: Josef Bacik <jbacik@fb.com>
49af9ed
---
49af9ed
 net/ipv4/inet_connection_sock.c | 2 +-
49af9ed
 1 file changed, 1 insertion(+), 1 deletion(-)
49af9ed
49af9ed
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
49af9ed
index a1bf30438bc5..c039c937ba90 100644
49af9ed
--- a/net/ipv4/inet_connection_sock.c
49af9ed
+++ b/net/ipv4/inet_connection_sock.c
49af9ed
@@ -321,7 +321,7 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum)
49af9ed
 			goto fail_unlock;
49af9ed
 	}
49af9ed
 success:
49af9ed
-	if (!hlist_empty(&tb->owners)) {
49af9ed
+	if (hlist_empty(&tb->owners)) {
49af9ed
 		tb->fastreuse = reuse;
49af9ed
 		if (sk->sk_reuseport) {
49af9ed
 			tb->fastreuseport = FASTREUSEPORT_ANY;