Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1958392imn; Mon, 1 Aug 2022 06:19:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Z8WFyPVpSZO2Mh1bA3tXSJEciJRC7+rqi+ThKN92OMvDZM+LynXMK/P84pByZgPQz79bJ X-Received: by 2002:a17:902:bd8a:b0:16c:dfcf:38ba with SMTP id q10-20020a170902bd8a00b0016cdfcf38bamr16381043pls.35.1659359945010; Mon, 01 Aug 2022 06:19:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659359944; cv=none; d=google.com; s=arc-20160816; b=QsLgiHl9kwK4xSx6X/cmrSJyxcYeYiQjPEWs9bgcByE9oRqSpsqt+GRLLkDttYoYO8 OsFfhPXhKS6z1o4DChNWKEjEh+y/c9Ceq1TjBW2gjMHqvlxAT+E5O08axV2JypQqimYp Kgp4/eQih2EoPynB3Wir89Ujo+OOZa+rL6iJC94OLZ70CMBDC0qUY0n5rFyU2J7mkCnp fDrOZ+XJOLMoChSE7YmzVraFN49zEoii/IMpM8J+xTQY2fCGFTFyb1KZp0Dl5Y3bCiar llMWBXPTIIjhYSzQY9fYvd6mIrof0H5U9GuRpgavXSqPnRiy3I3D/leIPvvkIPNm1ern jK5w== 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=4KUTCNaBwGVsK5LUHrpBhDtWTdg5pyrVmt0DNZ3FlC4=; b=nVyBswIQ2410GDN6hH1sGzoYcD7pBchb0luv7HBdXak46/DLgVX9nHhnHdbF9WdeIa fNNtUkJE50D/wCbdtRktBcypC90kJ46CB6h0n0mIQGekcAC74eCX9kBrcGnfiin9Zgtg kQnibLP/his71eUprofbXqAPkezsRjqvmATNAuswMklqgI1R5vUE9KrA5CTG7cbax1MT 01dqOfisksik3/wz8liZltqLxlBIoTvdvcxvFjyyxW2jWPgMbbJjLMpYcbmYFW/ONI3e qMFMDoWYoVdlTAqQPSqI4B6j+etUqDEMO2IDAaS8pD4rKd6DL2jmb7WNMyobZbvTy7mq qi/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J91oGVuX; 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 bc22-20020a656d96000000b0041c359673a9si1225374pgb.728.2022.08.01.06.18.50; Mon, 01 Aug 2022 06:19:04 -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=J91oGVuX; 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 S231851AbiHAMMB (ORCPT + 99 others); Mon, 1 Aug 2022 08:12:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233358AbiHAMKD (ORCPT ); Mon, 1 Aug 2022 08:10:03 -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 4303C66BA9; Mon, 1 Aug 2022 04:56:26 -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 598ABB8117A; Mon, 1 Aug 2022 11:56:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A12FAC433C1; Mon, 1 Aug 2022 11:56:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1659354984; bh=YHudctfQmkhEKzhY+0PNz1y00jvWGU0MMaSvDV3vGFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J91oGVuXPiGe4rsUhrhNWkrlvxtdGieyXyfV9Pgu8Lp8S9GnJJzOkpEzUE9WdXVA/ okTOGWWKPp9P+k94bqt4zzgMvazDeTHKOx2W7OjKByFSozdO0LO/etJ+f2Ug3wu/z2 6ErmKJR7sYFCXju/nUpN0eYlTvNj+i4bh8v3jT68= 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 5.18 20/88] tcp: Fix data-races around sysctl_tcp_dsack. Date: Mon, 1 Aug 2022 13:46:34 +0200 Message-Id: <20220801114138.963047102@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 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 @@ -4426,7 +4426,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)) @@ -4473,7 +4473,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; tcp_rcv_spurious_retrans(sk, skb);