Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp484760imn; Wed, 27 Jul 2022 11:30:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v8267+MUQhGk0SeZdlDjG+a9N5DgDXZNnubBY7N66cod+MfFRqzhLP4anXSbijsW19+C2k X-Received: by 2002:a05:6a00:cc9:b0:52a:b63a:4e5 with SMTP id b9-20020a056a000cc900b0052ab63a04e5mr23131213pfv.59.1658946613884; Wed, 27 Jul 2022 11:30:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946613; cv=none; d=google.com; s=arc-20160816; b=ZNHlfR2qgzAi4DuelFBDH3k3JnN80QW+1XPuLE/vRiR35PCuM+ivF0vplvR/VjBs6c 2YFZSM7MNm5imtywyfouRiW0aouPMciyVRs0sAKSS3HPYe/jTNX7mdaCgZm8R81hAIuv 4BGoD7hSx26zpbpGUa8Ckx5xejV0OMeRnSFAHY+suIbeF1YZ1GkpGUjiFURlfpKEzUWc lVgKu3dh6migq3oAD4N4Js+Va6IhapPsedd27YUiHGfO8fyW0YBYQWfGsGWGRnt7RSli sVQnoOzi7LHagbX3OnqPMQRTKNzJmYaMSP3y5EioGe44m6JUOMrxMjJo0Wc/QzmRAMtG wjJg== 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=vZB8jnAfkDtf7f8M7gaONYiujqdxx0yelCon7hlpvoE=; b=emT2zNM+NTjtDZooOnFk+hZKDbBs21Vf/Z7lQxYKxdX3SfODwEhx0K0UVp4xv9rXIC kaYXQb4J+tVKHH64rYNg939mHCeIx4/knnPhgVTFiO28OgWUybsDqzfk1zvyqlCF8sD1 gQ3J+5/21ff8PkPpellfvaQQssQx2Gv0nuYIziVTNTkMqll+xAbYaXBos7sjY/upfC/F i7oepR+84HDTTv/Xf8hM2O4l8vhuIi+NNd+eMmo4CWwr3MyvGm6wJcqg/IWMSHy7zLkr i60hIb3q6mSud+GS9+UBubXt6sHjum/7KCYt4OJbun27klk2l5vpSeO2sn52HhpXb8ah s3UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="052Rw/fQ"; 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 lb10-20020a17090b4a4a00b001ecb608ea41si3290213pjb.167.2022.07.27.11.29.58; Wed, 27 Jul 2022 11:30:13 -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="052Rw/fQ"; 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 S241458AbiG0RLa (ORCPT + 99 others); Wed, 27 Jul 2022 13:11:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241486AbiG0RKP (ORCPT ); Wed, 27 Jul 2022 13:10:15 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8CE550716; Wed, 27 Jul 2022 09:41:24 -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 F2E5BB821AC; Wed, 27 Jul 2022 16:41:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BD23C43141; Wed, 27 Jul 2022 16:41:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940079; bh=njFzzC6MTd3uWhSnu3HWPeCo5XsQIZZJ7INHpwE674k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=052Rw/fQRlq4dXPWOAoNfz4IaOmv1/1zlB7krAAOV1MnOiFw/ShzI4LzHHqDE4wAF 4lRLTPfwkejKMygrJGcXSNQpMn8aqXb4vrsN81a+oVw0xyWa+vkFiJvvwSWJLr6qDe cTWJHNYOmpADj+9JmROpcbw83EBXmT7jkNxWQS7o= 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 097/201] tcp: Fix a data-race around sysctl_tcp_tw_reuse. Date: Wed, 27 Jul 2022 18:10:01 +0200 Message-Id: <20220727161031.780390256@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 cbfc6495586a3f09f6f07d9fb3c7cafe807e3c55 ] While reading sysctl_tcp_tw_reuse, 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: Sasha Levin --- net/ipv4/tcp_ipv4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 235ae91bfd5a..fba02cf6b468 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -108,10 +108,10 @@ static u32 tcp_v4_init_ts_off(const struct net *net, const struct sk_buff *skb) int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp) { + int reuse = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_tw_reuse); const struct inet_timewait_sock *tw = inet_twsk(sktw); const struct tcp_timewait_sock *tcptw = tcp_twsk(sktw); struct tcp_sock *tp = tcp_sk(sk); - int reuse = sock_net(sk)->ipv4.sysctl_tcp_tw_reuse; if (reuse == 2) { /* Still does not detect *everything* that goes through -- 2.35.1