Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp480207imn; Wed, 27 Jul 2022 11:22:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vNgdC757C8wB/D1sk7o2JqFIDyru57VmT35H7n4TSW9Tz1nuusZTHstbn9mLvmhUpAVnl9 X-Received: by 2002:a05:6402:187:b0:43c:b095:4ab3 with SMTP id r7-20020a056402018700b0043cb0954ab3mr4624770edv.5.1658946143329; Wed, 27 Jul 2022 11:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946143; cv=none; d=google.com; s=arc-20160816; b=ImkrjUkZlxfXswpOithxevxofbVIq2Hv0v0Mf+aWV9hq32+O5/FXck6GMKNOTGqsQb Rnl9tUibGpQDq7IlDmzwI1QfY3S9HKQu+O400eNPxzYk+emnejhOQKN7F2k8CRkMzyLr NDkDZjuPAhCxqU7IcgqQcej9MmNSS+GZQ1gL7MnGquxDWEctxga6npRYN35VF6VGA/qr PQDaDdPGUALS9bgXMthCw1Ls++POWK5CU6BtcgySbrRkNIbTUDTCDyaFzsgr2ecsuieB mqrw9B8jfoSNtYciGdiR6Be58poH8bE1mp28gBARDGt1gHX8xP0nDb954Wcb4LZoqmZ7 djhQ== 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=HeM9kcWLdQ+zYVerK4B6MxlCf0NSLCtvsT2u1Tyeltk=; b=RcAFYurqGr0mSqsO6hL95GRP31zN70PTgaIoeBRIeiOU+J+WmIljuZZ17u9st+oYo1 SZVCUNyLYHmBkjRNGdyg33HHKxLS1ylEX1LRsA2PSCo4bWAclXQqR657WQQawItUM68C sLOnunwGtSTEPKsO/LNEug7jcfsxAWg9JpkISs4gGUTQVMOm9epa5HqYqMTYWEPoVRf5 0Ar07Jo39XUhTSoySUQn3O8h3/39YZansG30mFCUfnymMjHBWnOKnaRZTpcuP15B/A+9 nfIW1QjY0Nawb/jneyhgOzocLdDe0aFVPJHR4MsedE01Qp0CMKb9IA1SicAuhWdnjPvK gjEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WtP6eZH7; 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 hr22-20020a1709073f9600b0072ae569d6a0si22763781ejc.632.2022.07.27.11.21.57; Wed, 27 Jul 2022 11:22:23 -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=WtP6eZH7; 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 S239760AbiG0Ql6 (ORCPT + 99 others); Wed, 27 Jul 2022 12:41:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239122AbiG0QlP (ORCPT ); Wed, 27 Jul 2022 12:41:15 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E36C251429; Wed, 27 Jul 2022 09:29:36 -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 5C55CB821BA; Wed, 27 Jul 2022 16:29:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A70C7C433D6; Wed, 27 Jul 2022 16:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939375; bh=CRrSIL4P0svdiiR+e0jcJwxpGu2VL7VEQG0U7nfZTjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WtP6eZH75Ei/4yHidbTq3LDg+tsv22NYeL+z2QFAtVJrHCceJZPV7KfUBRJJXj05e h6K0saWDwbtGs0LrrNiwNYbfp+sFV2bYuESh6BrEDBtQLGb935nurp+XolZHNmPRXG cGOATgeHcKLPc71T0+mB2tLmVPtkCNk5aRBZL/Lo= 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 16/87] ip: Fix data-races around sysctl_ip_no_pmtu_disc. Date: Wed, 27 Jul 2022 18:10:09 +0200 Message-Id: <20220727161009.659742989@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 0968d2a441bf6afb551fd99e60fa65ed67068963 ] While reading sysctl_ip_no_pmtu_disc, 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: Sasha Levin --- net/ipv4/af_inet.c | 2 +- net/ipv4/icmp.c | 2 +- net/ipv6/af_inet6.c | 2 +- net/xfrm/xfrm_state.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 9ab73fcc7411..06153386776d 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -337,7 +337,7 @@ static int inet_create(struct net *net, struct socket *sock, int protocol, inet->hdrincl = 1; } - if (net->ipv4.sysctl_ip_no_pmtu_disc) + if (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc)) inet->pmtudisc = IP_PMTUDISC_DONT; else inet->pmtudisc = IP_PMTUDISC_WANT; diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 9bc01411be4c..b44f51e404ae 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -886,7 +886,7 @@ static bool icmp_unreach(struct sk_buff *skb) * values please see * Documentation/networking/ip-sysctl.txt */ - switch (net->ipv4.sysctl_ip_no_pmtu_disc) { + switch (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc)) { default: net_dbg_ratelimited("%pI4: fragmentation needed and DF set\n", &iph->daddr); diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 942da168f18f..56f396ecc26b 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -222,7 +222,7 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol, inet->mc_list = NULL; inet->rcv_tos = 0; - if (net->ipv4.sysctl_ip_no_pmtu_disc) + if (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc)) inet->pmtudisc = IP_PMTUDISC_DONT; else inet->pmtudisc = IP_PMTUDISC_WANT; diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 268bba29bb60..bee1a8143d75 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -2488,7 +2488,7 @@ int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload) int err; if (family == AF_INET && - xs_net(x)->ipv4.sysctl_ip_no_pmtu_disc) + READ_ONCE(xs_net(x)->ipv4.sysctl_ip_no_pmtu_disc)) x->props.flags |= XFRM_STATE_NOPMTUDISC; err = -EPROTONOSUPPORT; -- 2.35.1