Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6267359rwb; Tue, 9 Aug 2022 12:04:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR5cZMOA8oXkGVHRRcdbsMv8dWaiRm+rBdEVDx5vmuGuAF1ZQ2WmO4eXjTgkVTqcBgYRyTvJ X-Received: by 2002:a05:6402:27ca:b0:43e:ce64:ca07 with SMTP id c10-20020a05640227ca00b0043ece64ca07mr22618374ede.66.1660071898447; Tue, 09 Aug 2022 12:04:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660071898; cv=none; d=google.com; s=arc-20160816; b=Zw2CDISDb7n6vN3z0SX1wDB0HtrMJFbujaLm8JY6B81Z+GmO+/KYD/8ySduC0JryAL 9F5eN18l1Y9M3DFVsQjGcI8hOgl36z42xyXo/2jmld/84AXRGUWx69Bu3Dy1UO2xkrhx 9azrw5gnC3BeEyoy/wE3FPC7BczX6t3IfBNJyJj0kFqrBYfhF3pjIc0mPEB4mx0H5pvo rIrjDXnQCJUZSu4oduLIY2/r9tqEeTAYpZEvih20gjiwmcCSqLj0S+XxjO6fDutukWvY 8euhQ/H5E3ZprjiZIoJKcVxdQwWxxSebVjW084b3j8rks+zmblqZYTdLI0dnstuaDXho ZJ8g== 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=H+pTr2KiSOkf0v1DD2lwh7l8Nu4gh2P7Dy+BKXPM3JA=; b=LJfPsWH3bY2zrFnVRyhser2drE5HJvLE0962l+2EjdQK9jqAcq5yQtogal24ev4CmK tyd06gV76MTyBgcz1ERgTIcJZuEDvL05x/LXzItobl7vx/E2qSwdLc2XETysS95Eq28v VcHK6Fl/1nPUqzod/4nSmqEu6syURwSULpVwxP6g2GM1oNuRCFCopjc9rhhKnZ90vTpG 8eLUBaiG6yDFss8xCIrxYyY2aaDUxFPc8GuJmBViBefT4IuCqorLhJkT24NAenmpO71A DPu2830MGmsjoeVaQweFnmnheR3z6MODLm7uuBQtahuEl0qYZLisf6AWwAg9bKwaZVwU bpNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iOhBMOUb; 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 o7-20020a50c907000000b0043be4e916b3si8477329edh.126.2022.08.09.12.04.30; Tue, 09 Aug 2022 12:04:58 -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=iOhBMOUb; 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 S1343928AbiHISEV (ORCPT + 99 others); Tue, 9 Aug 2022 14:04:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344457AbiHISDL (ORCPT ); Tue, 9 Aug 2022 14:03:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3373D26ADB; Tue, 9 Aug 2022 11:01:51 -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 151AD61012; Tue, 9 Aug 2022 18:01:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82052C433D7; Tue, 9 Aug 2022 18:01:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660068110; bh=nWkaHB4aObE4+ORXQz/gbELbp69I+2ype2nxZe9a19U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iOhBMOUbVNQ52uVzKGFoOVHEBuoGke5N8942aYr5Ifsey68O0HTid97VCiRfs5+/a wgKfgy1cCuwG/NOq1ltM6EdHW2i/fXyO63gksfeTawZGkNdR4auWKsxYUNKDVgIkI7 6qibuxIxFUuwo2nYkduWsJi5OO4ef2JnRlsVpHo4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" Subject: [PATCH 4.19 08/32] tcp: Fix a data-race around sysctl_tcp_nometrics_save. Date: Tue, 9 Aug 2022 19:59:59 +0200 Message-Id: <20220809175513.362227305@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220809175513.082573955@linuxfoundation.org> References: <20220809175513.082573955@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: Kuniyuki Iwashima commit 8499a2454d9e8a55ce616ede9f9580f36fd5b0f3 upstream. While reading sysctl_tcp_nometrics_save, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp_metrics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/ipv4/tcp_metrics.c +++ b/net/ipv4/tcp_metrics.c @@ -329,7 +329,7 @@ void tcp_update_metrics(struct sock *sk) int m; sk_dst_confirm(sk); - if (net->ipv4.sysctl_tcp_nometrics_save || !dst) + if (READ_ONCE(net->ipv4.sysctl_tcp_nometrics_save) || !dst) return; rcu_read_lock();