Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6137185iog; Thu, 23 Jun 2022 12:07:24 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sFDPKuTfVSTz/OACYT+/Q9KcjgxVXupvKob/EHrUKZmECnrnGJZsSU9wsMZ4bEGSSw2SCT X-Received: by 2002:a17:90a:c244:b0:1ec:d65f:e1c7 with SMTP id d4-20020a17090ac24400b001ecd65fe1c7mr5523982pjx.15.1656011244339; Thu, 23 Jun 2022 12:07:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011244; cv=none; d=google.com; s=arc-20160816; b=ISA4bEbn+06JiPWe3H/CvySv+fBsnELGvzct6WV/Wc35f41VJY97YjDINTjv6UsrCq ezHWXRnB54sdVH62Y2YAilE3PC1EKTShmtegw8je+namS7jwEJjaIKJkL0vZgfuS/rdP 9/Od+HyqTQGtceKNGU05HnR/pi5qHh/JQrGFTqy11CNfJqP9OiBRJOcBMj+QaXXTrQSb rKSWHj2n6Zzay+TnBt140OFWlfDWXaQNldQG4uUf9B6hFBAsOzw/Z2U95/8gcFIMCjej SVqYrwOUXQC2O7p79DOhAcImUJJwaTjV1IZdWOg6xe/qvWrf//O/8owJEk820x8E8vsb kAGA== 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=RKy0gdZF8e703m7nV1Jgwnu4ZbejkFa2qO4CY4s8V3Q=; b=I9IM6zwt/5eUbPi9xvuAEMj7RRavSurdV7M5LIGBSgd6rwedonolUXRd+Xbh+C51VU PdTVVQVCWTdzDbsGj0RyqXmsGpYhFwktKe9+FjVWWo9jJwRXN1szzRo7RqNBK1rf8cKE dftOjmMTRqwfdjzuQLrxDFGKFSdpd5IB1PShYKfZUV6bZ5Foq1Zt81puJ4kdH2sHh+Fl r4ap8kv3UlGbLPlDLTdVV2l/B87pvwBUgWmSvluR0oQTD/o4PUtpYR2vDags5q1SjRQk WMuTTomiO3vFH6uTZW3kZD1o8xphTMDd8iJFTvNGIG+YaOYM3Vk4jyS+lZSqOT0gneWF RPgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dvLCHPfI; 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 j8-20020a056a00174800b005255f483957si2730234pfc.210.2022.06.23.12.07.11; Thu, 23 Jun 2022 12:07:24 -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=dvLCHPfI; 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 S230405AbiFWRQz (ORCPT + 99 others); Thu, 23 Jun 2022 13:16:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233624AbiFWRNE (ORCPT ); Thu, 23 Jun 2022 13:13:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C84C56C08; Thu, 23 Jun 2022 09:58:56 -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 9C1DDB8248E; Thu, 23 Jun 2022 16:58:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFD6CC3411B; Thu, 23 Jun 2022 16:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656003534; bh=EWppoqrobli/wnWs+cs+6YShz2p82cWmm45XS2tvHAc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dvLCHPfI45Gz5SLDn89bNsEHgxU4JseMte+YxogC3Amc8fsKC3G+4LVKx663XrZbh mmVONun0vELwHux7tyG7s9YewoVOn6cEoUd+oQC+cWDkikMXc+yiUsh5v5+EWTjupo 4giw+AXzH5zZ7BLFL+daEbukL3r49AEKvLyaYWhw= 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.9 263/264] tcp: increase source port perturb table to 2^16 Date: Thu, 23 Jun 2022 18:44:16 +0200 Message-Id: <20220623164351.504831193@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164344.053938039@linuxfoundation.org> References: <20220623164344.053938039@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 @@ -541,11 +541,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;