Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6136648iog; Thu, 23 Jun 2022 12:06:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ssYW6K+AJ39DKUH2EOmDyWu/4XUSlBPNOjmsW2F/otdhFvTTMNTBV10QH4wPbKO0Q1znPj X-Received: by 2002:a17:902:d701:b0:16a:2206:9ba8 with SMTP id w1-20020a170902d70100b0016a22069ba8mr22685160ply.168.1656011209275; Thu, 23 Jun 2022 12:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011209; cv=none; d=google.com; s=arc-20160816; b=uY72XN4OLbxxwXQOpLtFH12XurZZ67KQ6uepOB0rQ+c+BLflxXnoycrHpFv2nTY25n GnpXpPHdkyYGm3eg1BhZHRuaLZ4zVPu+7Jbj9DEXUXz5EpkXRmfpDmN9mBIK2BqQA5jA L5FtaBLEm7yc6CIR2EHTC5WmtO/dT7YbS9UYjF6JdaPkSgNAfnD6Lm0dvojW6QZ7U8Fw vrKtLLX2PxRv9ycT4wr6h8kX7Pf1mNUqie6nvxPUyfyK30SwbUwKf9mgEEXThHgxdQoW umbVRhPd2bYU1BWHAP/4f8goPC7qG99PlnWTgCBrL0nlIVpAgVsrd27Wb49dVE11B1Bb wegg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8fk8ai8LEyncUHCb5EhRvjEIhP5Exs9GNMNGtVdKHuU=; b=HybS9fxjva/J83p1aMsAFeuh8XGWg/6mDHa5Csh3C+WZeLtdGi1/Pc92+P3w6WfOhW aYNLJDXgyDDg6KXAkrCzplbLe0Fs6SAM3LD1zady5vK9ezJGunUoQkUeymQWOalpqgkm kgzxuLStZUa8W1TNuDXs1sDxQg/t896aTvA7iZ08SpEhRHmACv02qtA5nnx6Oi1tTLWm um2XHlfIr+jom6r2feX5K0x72RE7K0CjeCucpGXcLlM9d+8LfWUszUfFnDZgogWt3vkT mJMyaOc2In5WOUhJOH+/1j3a/Bv4gK27GXdQzgCc8MvVpqhc5HU7IUxPg904geuWMSO+ WdWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BUEBMJ5M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mw16-20020a17090b4d1000b001e31047144fsi4879397pjb.132.2022.06.23.12.06.37; Thu, 23 Jun 2022 12:06:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BUEBMJ5M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236669AbiFWSVI (ORCPT + 99 others); Thu, 23 Jun 2022 14:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237064AbiFWSRn (ORCPT ); Thu, 23 Jun 2022 14:17:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83067647B4; Thu, 23 Jun 2022 10:24:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E4B4EB82497; Thu, 23 Jun 2022 17:24:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50821C3411B; Thu, 23 Jun 2022 17:24:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656005041; bh=vmkhwuKTuuFh4wvOQ1WNX6rSG0WLPtaP5giT/pJ5GyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BUEBMJ5MaVQryb/abuSPhzXCe81n9ku8FKKdCC7yO+Lg0k103ZW1yU51/mfnXsYIw CCkM5OJC+1iVfYH2pW0kpOtY3B23iNR/Qquv2hxw8wbvAmf5gdupgCr7OJ2srJfzKt fq9w1cpqmrk6/SEqko4sOdygtnW2zw38O7bXD8sg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Moshe Kol , Yossi Gilad , Amit Klein , Eric Dumazet , Willy Tarreau , Jakub Kicinski , Ben Hutchings Subject: [PATCH 4.19 232/234] tcp: increase source port perturb table to 2^16 Date: Thu, 23 Jun 2022 18:44:59 +0200 Message-Id: <20220623164349.615461075@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164343.042598055@linuxfoundation.org> References: <20220623164343.042598055@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Willy Tarreau commit 4c2c8f03a5ab7cb04ec64724d7d176d00bcc91e5 upstream. Moshe Kol, Amit Klein, and Yossi Gilad reported being able to accurately identify a client by forcing it to emit only 40 times more connections than there are entries in the table_perturb[] table. The previous two improvements consisting in resalting the secret every 10s and adding randomness to each port selection only slightly improved the situation, and the current value of 2^8 was too small as it's not very difficult to make a client emit 10k connections in less than 10 seconds. Thus we're increasing the perturb table from 2^8 to 2^16 so that the same precision now requires 2.6M connections, which is more difficult in this time frame and harder to hide as a background activity. The impact is that the table now uses 256 kB instead of 1 kB, which could mostly affect devices making frequent outgoing connections. However such components usually target a small set of destinations (load balancers, database clients, perf assessment tools), and in practice only a few entries will be visited, like before. A live test at 1 million connections per second showed no performance difference from the previous value. Reported-by: Moshe Kol Reported-by: Yossi Gilad Reported-by: Amit Klein Reviewed-by: Eric Dumazet Signed-off-by: Willy Tarreau Signed-off-by: Jakub Kicinski Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- net/ipv4/inet_hashtables.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -718,11 +718,12 @@ EXPORT_SYMBOL_GPL(inet_unhash); * Note that we use 32bit integers (vs RFC 'short integers') * because 2^16 is not a multiple of num_ephemeral and this * property might be used by clever attacker. - * RFC claims using TABLE_LENGTH=10 buckets gives an improvement, - * we use 256 instead to really give more isolation and - * privacy, this only consumes 1 KB of kernel memory. + * RFC claims using TABLE_LENGTH=10 buckets gives an improvement, though + * attacks were since demonstrated, thus we use 65536 instead to really + * give more isolation and privacy, at the expense of 256kB of kernel + * memory. */ -#define INET_TABLE_PERTURB_SHIFT 8 +#define INET_TABLE_PERTURB_SHIFT 16 #define INET_TABLE_PERTURB_SIZE (1 << INET_TABLE_PERTURB_SHIFT) static u32 *table_perturb;