Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1942357imn; Mon, 1 Aug 2022 05:52:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR7WQnVW/y91+7jw/tQABa4boXbu8dK2tJwOjLd2+nkhhj27e2D+l+Su5hxDfKnLXNIi6nZe X-Received: by 2002:a17:907:2c47:b0:730:8bbb:69a8 with SMTP id hf7-20020a1709072c4700b007308bbb69a8mr2942154ejc.38.1659358374803; Mon, 01 Aug 2022 05:52:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659358374; cv=none; d=google.com; s=arc-20160816; b=EL5uFrz5v5k7YnNB0bqVk+uFHBOGczF/Ut/QM36YHS9tl4xWjgkFN/pLlxj3S4kWAw TzocHakkosCm8+LMVkSW6j4qRmoJOF19WRdID0m+Xw32Ar7JzhAr35F+VHMMPDJUPkWF Rv86zvqAUEGcyoBuPTUSsnWjYd9xhf9DNVP48sXf9WAyBmQrYLZ9d0N1SiDJiMPmXxsC /0Cf9HyfWWUm0HopLE239pw6ZpY0MXMQyKXYW7oLCkKP3Vh4S7vj3mmZMXUVcdJ2WIbn YFbI2eOJeQKXgUa1nX+Dw96i7lfMPqtnE8VB+LlPHIJ2L0TUY/AhMQtvPAYnPayw1ZMk WZUQ== 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=lyiUcUTz3sXM0mNJStZhXfufU+GtqnCXpX1Oh12xxtw=; b=bwBCZaKNrMqlq6F8rTlsa87aD+62AT8u6Y4KQZvCniY0yvYUikNNtVoiocjUUNCAZG jnNUGC1jJlIWGN6tE1J/6qsSMOgRGLrnmzkJudR7hKOytmnb15Ooc9VVb1K/vWqz6rA+ rh6eeRIkv3b/XiJkChiDN8HGcDvatZt7YbS8yYjbXlh4SZ7ZYENfAXwOfpPb+XdvPgmi 48suiMD+9x4+RpwnTtTRZPsKN6x0mVxAdOlKrXCVDJ5KtAYztSuKO9UlRyvPe3WO3uiE B/0Lv+eNBA/PHIsUISyoIf6uF8BtywCbUf3RVZaWg50BDpQLeGsBvw8FnxhwVp8xnvzG 5/Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kZEpXsjx; 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 gs7-20020a1709072d0700b0072b474f829dsi13038175ejc.970.2022.08.01.05.52.30; Mon, 01 Aug 2022 05:52:54 -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=kZEpXsjx; 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 S234034AbiHAMQY (ORCPT + 99 others); Mon, 1 Aug 2022 08:16:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234189AbiHAMPL (ORCPT ); Mon, 1 Aug 2022 08:15:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06E0978DC4; Mon, 1 Aug 2022 04:58:13 -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 9BBC8B81170; Mon, 1 Aug 2022 11:58:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DD47C433C1; Mon, 1 Aug 2022 11:58:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1659355091; bh=F7T5biOEcTaFfcc4pS0uPhSCEkkPqFXDcQ+ZcZUxk9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kZEpXsjxjdOjyf3d+xDmQFNgXRuDcEz+EO9Hl8nlZr54RzXdAe515UvSVJ7U0PCPI kC84gmoocT4kVarDrSA14MpOjE1inYPHSGSCnnVHiSwx8W4w2qktoIfFNQVV3nZq5U aUKa9bVClb/d5SaHdXQjsZOCeKc2XQYecavkSPjE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 58/88] tcp: Fix data-races around sk_pacing_rate. Date: Mon, 1 Aug 2022 13:47:12 +0200 Message-Id: <20220801114140.696861219@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220801114138.041018499@linuxfoundation.org> References: <20220801114138.041018499@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 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: Kuniyuki Iwashima [ Upstream commit 59bf6c65a09fff74215517aecffbbdcd67df76e3 ] While reading sysctl_tcp_pacing_(ss|ca)_ratio, they can be changed concurrently. Thus, we need to add READ_ONCE() to their readers. Fixes: 43e122b014c9 ("tcp: refine pacing rate determination") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/tcp_input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index db78197a44ff..de066fad7dfe 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -910,9 +910,9 @@ static void tcp_update_pacing_rate(struct sock *sk) * end of slow start and should slow down. */ if (tcp_snd_cwnd(tp) < tp->snd_ssthresh / 2) - rate *= sock_net(sk)->ipv4.sysctl_tcp_pacing_ss_ratio; + rate *= READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_pacing_ss_ratio); else - rate *= sock_net(sk)->ipv4.sysctl_tcp_pacing_ca_ratio; + rate *= READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_pacing_ca_ratio); rate *= max(tcp_snd_cwnd(tp), tp->packets_out); -- 2.35.1