Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3560872iob; Tue, 17 May 2022 02:43:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1hGVb7NCz/CmQC7Myq9am9OZaBpOxugrG0WvdUlaLEKzS9GbYLVsd96pgiyCzfXcAT+xa X-Received: by 2002:a17:90a:9311:b0:1dc:8d06:eb1b with SMTP id p17-20020a17090a931100b001dc8d06eb1bmr23964273pjo.41.1652780613018; Tue, 17 May 2022 02:43:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652780613; cv=none; d=google.com; s=arc-20160816; b=rS6sjT+Q3h0J/Xv8l3BV0uR2E++P6NGBwF3sAZArhRjOwQGDvd2vUz3Pieu83Kb96i z5NFucxQHJtQz+Iy/0EUZ/5W1JXZD0exgM+MGq8cZTBdCCVujVbs4ddwjS+n5oqGzAKw +Nl6yZ2lDrVOUpbDw88Ulfy4/kijZngYIJuCafz8Ilb7pzG4dAezZG2sffTHeLgBNuIz vKH8nWZ49kd6oq8KwZxSHqz6bz/f1Jdq787FvUbbOzq3PmHDHHNpyc8bCY+Wbmmo7Jn5 0szsyqRZQ9gYcTsU6AtMyrbacPzx/CkmgTNV3Ch1W0v8uusTJ+DTDY3rhps2sDMUdmKf Jdaw== 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=jxQrw1sawwWY3FnYwPhVrnOX97STcdT5rpzhAaUxzjo=; b=L/eRyOTrO4IT+1hNM514sX825hwjLXINd0VcZeCbKvEJctHuQgEF1sof7kGUyVtabn jCPHLACKqX7bMo4FHiDkR4PgYorBYF2XkSVfZfDTHdcnUg5Q2tqBJtS9NvIxD3x6gd2a xQbBj5EZdvLUIBGYAAnYgfGdwJUHEODW31pP3hAL9/eTTxHGtoLIfbthQePXQ3ZXVl54 +cBOndjWUaHyXhQ9Tb96hCbEdG8NgUYJeA4gPMqOXckR2Tf0nD6imj4D/KzEMTJOlm3Q YLIlqeLivX/x2V89WNLn7+rUqqfPzZItUlsMqv9vXbto9Uuk4yLin1ZXsPHejc00RVzc mIGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ahwNEdnO; 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 a13-20020a65604d000000b003c5e1870569si14166049pgp.171.2022.05.17.02.43.21; Tue, 17 May 2022 02:43:33 -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=ahwNEdnO; 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 S1349145AbiEPUh7 (ORCPT + 99 others); Mon, 16 May 2022 16:37:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350993AbiEPUBy (ORCPT ); Mon, 16 May 2022 16:01:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4655147561; Mon, 16 May 2022 12:56:24 -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 070C2B81607; Mon, 16 May 2022 19:56:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70504C385AA; Mon, 16 May 2022 19:56:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652730981; bh=I5cs4rPMg6JZJCSn7sJ6TZVwO84ivOWm5OxLrZprd7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ahwNEdnO3eRpO7hnldwjHKoPjQdMa/nrf6nCzbv8hZuP4wsIeGReAbEiV0kC92QeE qwWpt+UJgGKwHMPBRTiWsCGYWfBvtGq9clpvyC9yKveTbHncGwEgwik95bBLtgOvId 4ov3rM76E6OiKxb7xhRJmQ8p4QLux3UfvC1TLVPc= 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 , Sasha Levin Subject: [PATCH 5.17 066/114] tcp: increase source port perturb table to 2^16 Date: Mon, 16 May 2022 21:36:40 +0200 Message-Id: <20220516193627.387650809@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220516193625.489108457@linuxfoundation.org> References: <20220516193625.489108457@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.4 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 [ Upstream commit 4c2c8f03a5ab7cb04ec64724d7d176d00bcc91e5 ] 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: Sasha Levin --- net/ipv4/inet_hashtables.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index 48ca07853068..cc5f66328b47 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -726,11 +726,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; -- 2.35.1