Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp499873imn; Wed, 27 Jul 2022 11:57:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vajVZ1VnIiASpNZti4eWNnU/RPXxy8c+Y6k0lDyES+rmx40Ex1cLqgq+bNN2GZHxJ1AhYS X-Received: by 2002:a05:6402:2425:b0:43b:20a8:ae8b with SMTP id t37-20020a056402242500b0043b20a8ae8bmr24202818eda.234.1658948260320; Wed, 27 Jul 2022 11:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658948260; cv=none; d=google.com; s=arc-20160816; b=07B92nxZhtqNdqXFjXXdwBR258ewtg7SvrFbsjqaFGWDJiEhaJ3AiZFQiC3fr69Mre cUjvVGnnVaOMPrYUmYcOElgWYsP+C6N4zLeblDvFIwJuW36ypyjGiKuqWGxF27ge+tfn jo3Ou00zOEIvvkTbISkaVJeNkg5pJKdjimReix7h0UH+vgFPhiF9rNesTx82+jsr/2er 0Uc+HcRAUh7XnY6hUHcfx6FmAyEtmSYGFoBEEuAzmcANX6bq+JiDgFF1pYYHtd4GixdG zuyt3TVRHGRDCeIXc64CApZHfQjlmMKY3eJDXHrWiE6o/sAfZ1to2IbOD51MnuAkqCYe jT0Q== 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=N+WdidHt4iFroguqT4UBMoUWu1dRQddyw/3ba2yt7MA=; b=swvRU5KJ6Y/cflTXBwbhK/P8JZZ1hKTX7nzWLsXDZB5ltMQ+SiCmlehB+sag8ywvVV mpgAmUEb8a2m6121cUoE3OUMH0gfMSqpTI4d5ujdJgxtGz13DytmKlYELkhGkV54PHTI yLSOVwv70h46iKW/b3l/50pgbBtrgiM25CvNqUda6Zbe/lmhJtkDCqD/sMyXWVoCKkM8 VdbnICce9fUYMgxeDVPWjEyJufF6XOaYN741ANEDQNZxQLTKfvQYngPsF2hnp86t6Q29 Zu3aKNlwC4LuRlyEli1hozfGxYpbSmfc4YoeFIcU7b0EBhz8tGd1MN6lUN/tHqgwwiG5 NVJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FQ1vD2S7; 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 a64-20020a509ec6000000b0043c8997b44dsi4383141edf.384.2022.07.27.11.57.15; Wed, 27 Jul 2022 11:57:40 -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=FQ1vD2S7; 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 S229669AbiG0RPe (ORCPT + 99 others); Wed, 27 Jul 2022 13:15:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241695AbiG0ROS (ORCPT ); Wed, 27 Jul 2022 13:14:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FDE55C343; Wed, 27 Jul 2022 09:42:36 -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 9047BB8200D; Wed, 27 Jul 2022 16:42:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2A04C433B5; Wed, 27 Jul 2022 16:42:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940152; bh=PTRFrZDRpHKYilPDjVYSyUzsHuQy8mpEheU4eS0zltc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FQ1vD2S7/1J8MA41qDrH/y9RMJH/Sllv5b2EBpO6Ob4IwK673cKo9zQymCILasTiQ s4mRci3iLp0h9xO5s6jD04vWTP1sqlOXRr6Flf/JzGqqvlaQXDklGNKSyre4/rEq4X XOnBYSYtMxnQqCS1szxPTUG7taTH8tG6Y/2/TkCA= 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.15 123/201] tcp: Fix data-races around sysctl_tcp_recovery. Date: Wed, 27 Jul 2022 18:10:27 +0200 Message-Id: <20220727161032.863019347@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161026.977588183@linuxfoundation.org> References: <20220727161026.977588183@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 e7d2ef837e14a971a05f60ea08c47f3fed1a36e4 ] While reading sysctl_tcp_recovery, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 4f41b1c58a32 ("tcp: use RACK to detect losses") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/tcp_input.c | 3 ++- net/ipv4/tcp_recovery.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index dd10a317709f..1cc0aca39c04 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -2087,7 +2087,8 @@ static inline void tcp_init_undo(struct tcp_sock *tp) static bool tcp_is_rack(const struct sock *sk) { - return sock_net(sk)->ipv4.sysctl_tcp_recovery & TCP_RACK_LOSS_DETECTION; + return READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_recovery) & + TCP_RACK_LOSS_DETECTION; } /* If we detect SACK reneging, forget all SACK information diff --git a/net/ipv4/tcp_recovery.c b/net/ipv4/tcp_recovery.c index fd113f6226ef..ac14216f6204 100644 --- a/net/ipv4/tcp_recovery.c +++ b/net/ipv4/tcp_recovery.c @@ -19,7 +19,8 @@ static u32 tcp_rack_reo_wnd(const struct sock *sk) return 0; if (tp->sacked_out >= tp->reordering && - !(sock_net(sk)->ipv4.sysctl_tcp_recovery & TCP_RACK_NO_DUPTHRESH)) + !(READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_recovery) & + TCP_RACK_NO_DUPTHRESH)) return 0; } @@ -192,7 +193,8 @@ void tcp_rack_update_reo_wnd(struct sock *sk, struct rate_sample *rs) { struct tcp_sock *tp = tcp_sk(sk); - if (sock_net(sk)->ipv4.sysctl_tcp_recovery & TCP_RACK_STATIC_REO_WND || + if ((READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_recovery) & + TCP_RACK_STATIC_REO_WND) || !rs->prior_delivered) return; -- 2.35.1