Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6267579rwb; Tue, 9 Aug 2022 12:05:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR7DmRrLwer5LINHDvEz01aBYr/s75bOXzOJVGavZ5DK4UY9HC/Qx4q0HWIwvotIXBkEP9QG X-Received: by 2002:a17:907:272a:b0:731:4699:b375 with SMTP id d10-20020a170907272a00b007314699b375mr9338851ejl.633.1660071909510; Tue, 09 Aug 2022 12:05:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660071909; cv=none; d=google.com; s=arc-20160816; b=Lb0AdACP79l/t68C+uzJOpQNpyd+v6svIXn0enNGqaOBO6BKCpQ6TiRzOnCWGsRGzo 5ao1ZFheiw/Z2rEsxo7Xod+FLcLxtzYBiclPMINE/OyWL6TfsDS9iUQFKj4mFzHda6f/ +hGHoVY7rrjb+lAB0vsQ3HScgPfjDBvFcCGWicwhGBwnNHOEHdAgGu0tVYvEPo8hc+q/ 3eYqjVFf17l49wUgAkmcz811Yboel1Tz7z28EJwqD1Tz53+ZGYkWIFUrsw+wgivV+gdA 4IQVxQpVK6G5gcD8TIHbd9Nzj8OyLIfYmvP73bjaTUnEnj9rlDeMLfLMbd1rWFWPcb0Z FanQ== 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=MW+NMUT9aOtZfgFNzKJKS80W1yOoOauXCPk+I03KH18=; b=ZzhVrxrZrqA7DNeCMZPtonDKEezm81a+i6v+i0ba42uwUzZygzseqHgzfgP0SEyfvW 3IbkzJWgc+LfcfHfpMnYR2c1tsu7LkBJHdFTumNHLqjSirPkFOjn2UcF4MZvSu9IzX6I +BHYouutQwXUVvTQ+HxmBgJ+XFHn7IhGuRr9jYsL/P8NhODJLYMcLxdYBIqcVevTZ+ys iQztoNib2QpMegaMGXn/1qbFcr4tAgRKRP6a5fADbjeTwmL8IDZ7AceRPN4I+v4Ebl5a TgwGD0UFi/t+UY/GFsbTmX2e6Dcwyw4JDj0zwSUc4MlNYnLYSxxGJw8SbZrbuWPcytog sX7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kaUcqYag; 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 dc24-20020a170906c7d800b00730d5c88eaasi2216233ejb.732.2022.08.09.12.04.30; Tue, 09 Aug 2022 12:05:09 -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=kaUcqYag; 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 S1344536AbiHISDt (ORCPT + 99 others); Tue, 9 Aug 2022 14:03:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344414AbiHISC4 (ORCPT ); Tue, 9 Aug 2022 14:02:56 -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 E919C27177; Tue, 9 Aug 2022 11:01:39 -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 CAD9D61050; Tue, 9 Aug 2022 18:01:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E941C433D6; Tue, 9 Aug 2022 18:01:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660068099; bh=/2+d9OPR6NFLDRBEJdCKTHd7LGem0wQnA1LurVjf3iE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kaUcqYagmuoo9R3zvY7uGHtilVeOfWDbcRL0I9UqwmO2PjVlvXI3l2572OTaCSb1S XX2mrDFV3W6qHtyzriS6+ywz/yBKWl15B0PgUOA8GC1HEXswEcBBnWADPyRMSJvZPV XdQzcfoyqO0C1Yd2TVLGvBSV8u+19F5qIbK7gYEA= 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 04/32] tcp: Fix data-races around sysctl_tcp_dsack. Date: Tue, 9 Aug 2022 19:59:55 +0200 Message-Id: <20220809175513.231288785@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 58ebb1c8b35a8ef38cd6927431e0fa7b173a632d upstream. While reading sysctl_tcp_dsack, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. 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_input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4197,7 +4197,7 @@ static void tcp_dsack_set(struct sock *s { struct tcp_sock *tp = tcp_sk(sk); - if (tcp_is_sack(tp) && sock_net(sk)->ipv4.sysctl_tcp_dsack) { + if (tcp_is_sack(tp) && READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_dsack)) { int mib_idx; if (before(seq, tp->rcv_nxt)) @@ -4232,7 +4232,7 @@ static void tcp_send_dupack(struct sock NET_INC_STATS(sock_net(sk), LINUX_MIB_DELAYEDACKLOST); tcp_enter_quickack_mode(sk, TCP_MAX_QUICKACKS); - if (tcp_is_sack(tp) && sock_net(sk)->ipv4.sysctl_tcp_dsack) { + if (tcp_is_sack(tp) && READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_dsack)) { u32 end_seq = TCP_SKB_CB(skb)->end_seq; if (after(TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt))