From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86504C433EF for ; Tue, 10 May 2022 15:49:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346323AbiEJPxT (ORCPT ); Tue, 10 May 2022 11:53:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346412AbiEJPu7 (ORCPT ); Tue, 10 May 2022 11:50:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60D5628B681; Tue, 10 May 2022 08:45:08 -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 dfw.source.kernel.org (Postfix) with ESMTPS id D253E615AE; Tue, 10 May 2022 15:45:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAA5FC385CC; Tue, 10 May 2022 15:45:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652197507; bh=bDtPcSboLQbfZJjHkkp3qfo4UrMu5pxU6qaeAryw3ss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZJDyUfqoWD1TXBb75z8uUTZQGADEyY/Vm2k6OGvvd//tn2b9I7QPMLYWW+GeHIKR1 5zujT3Xr4LyToLWecJpb/96xHeg9iJi+Ek/6cig/y6FoPROB2s4nixYO8Zr6GyUcEX EtImhPOc/G/31ksO46J2Lvc2FxBMR7fAMAdEfqmbbFLNXrWEW9mKbdXpzjKcyQ2iTA k8bQ4Io8HRn5Uo/2WtLO4vUUtYJ1jYK1w1KMiD6ndg5IH15bTtR5289gjA2HD3E9qP gvBPp7qma2A0hThfDDKyuKJWXyEFgNIKCfXYmQLGZyXTGvgKU+iGA8FXEJMJJDVNXh A20c9jGfasV8g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Willy Tarreau , Moshe Kol , Yossi Gilad , Amit Klein , Eric Dumazet , Jakub Kicinski , Sasha Levin , davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 17/19] tcp: increase source port perturb table to 2^16 Date: Tue, 10 May 2022 11:44:27 -0400 Message-Id: <20220510154429.153677-17-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510154429.153677-1-sashal@kernel.org> References: <20220510154429.153677-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit 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 763395e30c77..f76e4ac1ba3a 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