From patchwork Thu Apr 28 20:11:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Craig Gallek X-Patchwork-Id: 616402 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3qwnzW5M5Jz9t93 for ; Fri, 29 Apr 2016 06:11:49 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753275AbcD1ULs (ORCPT ); Thu, 28 Apr 2016 16:11:48 -0400 Received: from mail-io0-f173.google.com ([209.85.223.173]:36131 "EHLO mail-io0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752819AbcD1ULq (ORCPT ); Thu, 28 Apr 2016 16:11:46 -0400 Received: by mail-io0-f173.google.com with SMTP id u185so102149819iod.3 for ; Thu, 28 Apr 2016 13:11:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=mebpK6ZEBqQcVsln+hyCFx2JfBLdaX7NKXLz5V+6MNw=; b=jpVWCu+E/ImAielflgX/TGP5kgOAUOa25JqECNGWr+PtCuz/gJotnxGRsjLKsfCeVn z7dw9bz4veg1CONrEAl5Ctr9ANQK85KfY/5a1JYOd9E7sTYy+tb0X0uGYAHONDrmyg7B 6IbCoei8NfrnG+tuQZsxxoMgyl4HIv9niDzpUcWjCCHTs8C87cwTSvswfYESd/hdC1Qa OkvjDUHvg6758ml1dxcgCGu1+5LZdCMfRrndEZhp/VzyGmqHlZNadL0+jTjmkePt15xI OAGONeL4opy4TGu22ttGyn1oCE0guYVtwPdT+o3AFZVAZ2LVj/iuKYuwt8bNTfb0B5s4 Im0A== X-Gm-Message-State: AOPr4FW5U93kzH4i9olykGVPtCqzyz84uzvcZwxdWMnvrvlAiuQ5mZCWNTq4imla8AsG/Tqn X-Received: by 10.107.160.137 with SMTP id j131mr22737313ioe.171.1461874305861; Thu, 28 Apr 2016 13:11:45 -0700 (PDT) Received: from cgallek-warp18.nyc.corp.google.com ([172.29.18.56]) by smtp.gmail.com with ESMTPSA id i74sm8211967ioe.37.2016.04.28.13.11.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Apr 2016 13:11:44 -0700 (PDT) From: Craig Gallek To: davem@davemloft.net Cc: netdev@vger.kernel.org Subject: [PATCH net] soreuseport: Fix TCP listener hash collision Date: Thu, 28 Apr 2016 16:11:42 -0400 Message-Id: <1461874302-18258-1-git-send-email-kraigatgoog@gmail.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Craig Gallek 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 --- 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..326d26c7a9e6 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->port == tb->port && sk2->sk_reuseport && uid_eq(uid, sock_i_uid(sk2)) && saddr_same(sk, sk2, false)) return reuseport_add_sock(sk, sk2);