Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6140979iog; Thu, 23 Jun 2022 12:11:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u8fvLFgoT3BA9KzFPnB7wkhx2mcyqwTU1+iG0pNTV5bTX82Ey8RgjbyDwEloScxphhSle7 X-Received: by 2002:a17:906:77c9:b0:722:ea38:9979 with SMTP id m9-20020a17090677c900b00722ea389979mr9664445ejn.95.1656011509631; Thu, 23 Jun 2022 12:11:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011509; cv=none; d=google.com; s=arc-20160816; b=O3UY/7y1HxGGfxREtkFLx5OB4E7GFfjnItXNlr8YSYfAAS3sbg7b3oNbHUMz+dksMn 6UKa/Le2IkPjfQOJZtjNd2y/jpPWdXGrT82MvLk31xiTOKRFVxjNlfQZnjvfZpD9XBkO o51nQo03B5loVKhP1yZ4NfpHwkAVCr2hDBSZXRH88GMKg6JrFxljbfbBzIAq7SeXnNNX 6Su642k5/H+OijIB5/cElGZjUukYlnGUsj9wi4XsEK8WNrivFajanRiSePvBncDAEtsQ v9+Xqk7Lbbs3DGM6t5xsJBwmzdohOmjdiocPfL2xtaoTDWeC9+Hgc4750blv/jY9mA4x wkPQ== 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=qSvcEI0JoYPGZuUWWDpthCs8twQx3is1IPDvjSU1uWE=; b=oyM8iwQM+uasIEm/kI9p/XEdlaZ6CfgHQj+cjEgGIxQWWEolAXiA+GQxShfTtqT8Wh DdO16Azy/LnYg8jr1p/xzZv3xqc/BMMkA+v9OgWPnRnaXIzTeSkHNP5dUPr+rnHgxR1a mn0bK7uBYiL/FxgT/9OBapS+Jwvu6RcngTw15zS1i0akF3OjtWHMMaFTYpR+tph653wd nLvWRFuei0dZaUM1+uoKcg+otcRZn4lihYmO1xVMGER1nLUUvPFwhPL3xnoSJx7WkWBo p9hd0iT8sk9rV8OmWejangu8sYMMvEfJD7Avw33C5ROUBdVhc8ggOhpFlJXI1y7U2DH6 +Gmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=W7jx6+0G; 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 f19-20020a50d553000000b0042b370f9819si334515edj.552.2022.06.23.12.11.24; Thu, 23 Jun 2022 12:11: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=W7jx6+0G; 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 S231605AbiFWRQ5 (ORCPT + 99 others); Thu, 23 Jun 2022 13:16:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233672AbiFWRNL (ORCPT ); Thu, 23 Jun 2022 13:13:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 695AC56C1C; Thu, 23 Jun 2022 09:59:00 -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 E58C3B82497; Thu, 23 Jun 2022 16:58:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26EEFC341C4; Thu, 23 Jun 2022 16:58:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656003537; bh=zfff5ktFp8q2F8hrwm3GB33/6mYISFpaDC+KkmOGjT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W7jx6+0GerpMrRo3JRuPeZPuZ1PrIXBIFbXQSmVs1i1TNHClAsA1pBqt3TFPuj8FK 1U2CfgxKOaEXNJhhyijzLfS0T56WUS1NFaQMILwRplElIHTzEseg4ss10eFpFbLRwD 9B8lu2jifxFGhTrtfLgxeOAN0QvGXcQcsDkc5apo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amit Klein , Eric Dumazet , Willy Tarreau , Jakub Kicinski , Ben Hutchings Subject: [PATCH 4.9 264/264] tcp: drop the hash_32() part from the index calculation Date: Thu, 23 Jun 2022 18:44:17 +0200 Message-Id: <20220623164351.531874591@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 e8161345ddbb66e449abde10d2fdce93f867eba9 upstream. In commit 190cc82489f4 ("tcp: change source port randomizarion at connect() time"), the table_perturb[] array was introduced and an index was taken from the port_offset via hash_32(). But it turns out that hash_32() performs a multiplication while the input here comes from the output of SipHash in secure_seq, that is well distributed enough to avoid the need for yet another hash. Suggested-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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -590,7 +590,7 @@ int __inet_hash_connect(struct inet_time net_get_random_once(table_perturb, INET_TABLE_PERTURB_SIZE * sizeof(*table_perturb)); - index = hash_32(port_offset, INET_TABLE_PERTURB_SHIFT); + index = port_offset & (INET_TABLE_PERTURB_SIZE - 1); offset = READ_ONCE(table_perturb[index]) + (port_offset >> 32); offset %= remaining;