Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp480667imn; Wed, 27 Jul 2022 11:23:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u6BewSQzXkLsIaWwwaUvMA8cBHh9f4uPE1isGearEHvgT3SFqyq8VmtufRMis7hpXRB39M X-Received: by 2002:a05:6402:3708:b0:433:2d3b:ed5 with SMTP id ek8-20020a056402370800b004332d3b0ed5mr24356466edb.246.1658946197672; Wed, 27 Jul 2022 11:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946197; cv=none; d=google.com; s=arc-20160816; b=OmFg7pI8pkZZN9V1NLlUAMHKJohbTIOhgog+iy7p0SfJN8Jon22pj5amza1mhzSRk5 2XKUKPMmz5D2E+PwQjl/ZkcyPXmr3yVtY3h3Jo9vpwsIdQG96H0OmCK/QBAeBHZbAH00 GZMYsV3uqtNY1z4M4ZwS0aCn3ZYfVBQfleRi+hkkMgjd5Z22MlHItu9E387fcRkdGI12 Y4lOyLdFya6HeDcEip4irDqVfCaPJXBgEwjB2MXb0S08L5PmDlE9doENLOg/GpnBRIol nR29aHmU81Uk0UNaBaDeREfIfrwvfo2WxQhiF5rAXXuuE/u4TUu1d8jWNv+Ak25JM30P LwBQ== 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=D2vOE5tiE/p4YtvtCkwptVgGAYrGf/+Fnb3auK5bV6s=; b=CDxXeYBopA9wEhg4k/UOCsLAJUZBFz2fuEck/JOVxNVkbt7n8j01okk0omiPR8yW84 3my0S41Pqhcu5F6gxsZefBcQuxs+/a2hduSaTZ6Ma1+pC2gNGIym4QsTU7Se2F7D6te1 /whvc91P1ffMsq8YK0vgy8VuZdJrVRBv0AjWTEqGekh8l4qldKoekoVMi0wc6Uz+GB7w kDdsZD9exKnoKCdmrH4/z0TfT4BW10TRVweogwIAPjRsiebQo24MkXYB37nkFNblW94d 6HnsltOvxBiVbxKOjrEaD/Mb/6y4QvTxOTod1/Gw4yVpPsbvHq+pZkr6RNILvaGqAs/I epFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e2YbXtlC; 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 sc34-20020a1709078a2200b0072f1b3ebaafsi22483035ejc.136.2022.07.27.11.22.52; Wed, 27 Jul 2022 11:23:17 -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=e2YbXtlC; 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 S240421AbiG0QqK (ORCPT + 99 others); Wed, 27 Jul 2022 12:46:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239849AbiG0Qou (ORCPT ); Wed, 27 Jul 2022 12:44:50 -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 AAC4A5F986; Wed, 27 Jul 2022 09:31:23 -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 8CB5861A38; Wed, 27 Jul 2022 16:31:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A6BBC433C1; Wed, 27 Jul 2022 16:31:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939483; bh=5sBIDrAeZCj2hefEhVNQeE//wJyI0ZVlN15c+IC1zaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e2YbXtlCjksN+zW+xwIlKa8pDXTeZe7fg2umwWdzrqgq077JAbrqGwYs3q9SWyIJ9 HLZZ8lKDnu4hKNIrF6QX2HHdHt+1vbGAk2mPsmQIYnqxSZsNwfNNIx/GIVaBz1/irA wLi2xl1GQTb/gctOMUf8adYGqUdybC7JxAKQ2D1U= 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.4 54/87] tcp: Fix data-races around sysctl_tcp_max_reordering. Date: Wed, 27 Jul 2022 18:10:47 +0200 Message-Id: <20220727161011.260536841@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161008.993711844@linuxfoundation.org> References: <20220727161008.993711844@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 a11e5b3e7a59fde1a90b0eaeaa82320495cf8cae ] While reading sysctl_tcp_max_reordering, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: dca145ffaa8d ("tcp: allow for bigger reordering level") 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 f9884956aa13..c151c4dd4ae6 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -905,7 +905,7 @@ static void tcp_check_sack_reordering(struct sock *sk, const u32 low_seq, tp->undo_marker ? tp->undo_retrans : 0); #endif tp->reordering = min_t(u32, (metric + mss - 1) / mss, - sock_net(sk)->ipv4.sysctl_tcp_max_reordering); + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_max_reordering)); } /* This exciting event is worth to be remembered. 8) */ @@ -1886,7 +1886,7 @@ static void tcp_check_reno_reordering(struct sock *sk, const int addend) return; tp->reordering = min_t(u32, tp->packets_out + addend, - sock_net(sk)->ipv4.sysctl_tcp_max_reordering); + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_max_reordering)); tp->reord_seen++; NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPRENOREORDER); } -- 2.35.1