Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp485186imn; Wed, 27 Jul 2022 11:30:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1toRV99Q1oJqa/9Qf2el6SyG8xCBXCNxNYSFlBSFKz6gYYUkFk3KqF1g6G52erBKf1ZURDi X-Received: by 2002:a17:907:7f05:b0:72b:5a11:b357 with SMTP id qf5-20020a1709077f0500b0072b5a11b357mr19194126ejc.67.1658946653030; Wed, 27 Jul 2022 11:30:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946653; cv=none; d=google.com; s=arc-20160816; b=N4Q/K7UqelWdrDTiZ/YyYNWIbHqceUmrNSd3tkYvn9lGLWCpKavUs0aTWFdj9qmFDM N/a2XEvx6OkWFSJpUhC7fgcZxtJUgL4mM8M2TdD0hoI3Lsny80V6gTOnrnVwFpUZoXRT 9zvU58yeEZKYHmCXbQPzCMfnyNZACHjYkKElsVkfIHYh7maM59p5QzyoxL/ZEzYT9Fhy 9nhNPs7A1gpyvJSOcFDI6vaw5+ilSw39ZoGsEDxMUe8t1Ktf4TFnDtC08jXvHno9tfar NTm9j3gdv+WFWB7Bf7ReU7fccAaEDifpyCDNzShrHfPzAvuJVIOjGzkf/CpBDgATMn/I Bt2w== 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=LIubboZEbLEnutbE/2q+0rI574umtH+uyCQeXiaM1Q8=; b=ebX949eqzNyDqSb4gWLworAA9z1H1fKzWY5YWaFmPviCoK5ykZKt0cF9REW8XxiTTp vxLTx2iKrnA4rnlIsQt1I4JZkrI5zhNYVbOvjCt+xPeoT4C8O6ASVC8p+DyJF8gIZAEr B2Wja2bkbWh0zqfDdyvIYgA3H5xakErWTdpH20OKNECokdbB9X5duBGLHoct5izkkjb3 z14Trvq3X/OGkHbEwG3AIIe6COnUM16PlI9gjjZYuIIrWnjvIbAnKrr2W0JQffw2UuVN aYzLPoLZ5Do/DotCMqOh6koG5CM9Ow3s6KiRcavA4tGDD/yZkeZqT/K11rNF454ZeQTO qQAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=giGcAc4V; 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 l6-20020a056402254600b0043be0095153si14298638edb.439.2022.07.27.11.30.27; Wed, 27 Jul 2022 11:30:53 -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=giGcAc4V; 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 S238309AbiG0Qjr (ORCPT + 99 others); Wed, 27 Jul 2022 12:39:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239153AbiG0QjA (ORCPT ); Wed, 27 Jul 2022 12:39:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87BA44C63C; Wed, 27 Jul 2022 09:28:42 -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 7FEDC619FD; Wed, 27 Jul 2022 16:28:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B892C433C1; Wed, 27 Jul 2022 16:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939302; bh=MoYEj7eAG+6DjitY8iEdsOqKj5O7i39pKXTevkVBEgs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=giGcAc4VGeEkENfNPF2fmOYs8kXYx/Op7T8DSm6aYdaxDIF/+BIvq0bGS2sVWVeha 5vriFdzEb+u01D0cQzKz6sk+v7cI/A7yCGf6h26sz7rD3nvd0JYkiccjVVoeAq8uMN gKuDslnCeDVFpm3G0G/q6iX1Jve2dEzleyzgtvaU= 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 22/87] tcp: Fix data-races around sysctl_tcp_base_mss. Date: Wed, 27 Jul 2022 18:10:15 +0200 Message-Id: <20220727161009.919908958@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 88d78bc097cd8ebc6541e93316c9d9bf651b13e8 ] While reading sysctl_tcp_base_mss, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 5d424d5a674f ("[TCP]: MTU probing") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/tcp_output.c | 2 +- net/ipv4/tcp_timer.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 5ac81c4f076d..b84bedf2804a 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1540,7 +1540,7 @@ void tcp_mtup_init(struct sock *sk) icsk->icsk_mtup.enabled = READ_ONCE(net->ipv4.sysctl_tcp_mtu_probing) > 1; icsk->icsk_mtup.search_high = tp->rx_opt.mss_clamp + sizeof(struct tcphdr) + icsk->icsk_af_ops->net_header_len; - icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, net->ipv4.sysctl_tcp_base_mss); + icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, READ_ONCE(net->ipv4.sysctl_tcp_base_mss)); icsk->icsk_mtup.probe_size = 0; if (icsk->icsk_mtup.enabled) icsk->icsk_mtup.probe_timestamp = tcp_jiffies32; diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 57fa707e9e98..0c3ee2aa244f 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -171,7 +171,7 @@ static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk) icsk->icsk_mtup.probe_timestamp = tcp_jiffies32; } else { mss = tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_low) >> 1; - mss = min(net->ipv4.sysctl_tcp_base_mss, mss); + mss = min(READ_ONCE(net->ipv4.sysctl_tcp_base_mss), mss); mss = max(mss, net->ipv4.sysctl_tcp_mtu_probe_floor); mss = max(mss, net->ipv4.sysctl_tcp_min_snd_mss); icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, mss); -- 2.35.1