Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4373290imw; Tue, 19 Jul 2022 05:34:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ufS91rXTjYqxZ2veZ+3YYwayJGkXjoGqi/mG+2dl36094XSK9934yEyVmXx3LogEkRt8Rn X-Received: by 2002:a4a:864b:0:b0:425:71ed:ada7 with SMTP id w11-20020a4a864b000000b0042571edada7mr11081423ooh.92.1658234041652; Tue, 19 Jul 2022 05:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658234041; cv=none; d=google.com; s=arc-20160816; b=nOacfjr7Nff2yHFElzhl1yO45QfoFYRISlECSawvkxi9IDHv9mL2gBmitZlUNJx1HL LIbFvfGrmYFKSnr8O//qGSrtd695oOnoQjV7rFzOZFJMC5KQy+/jnYaZAVsQP/KEfilb ijhsxQTobObNdiSq28PAsWBtEWIPHF4wJ15KKALCPsucqtNehXfpCrfSD43HkGM4MUJB r0ij6PmmKOtXL6UkHlyJr0w1+1Kjq/W7siz8teVlPpSVNigcTYYh09G5JYXs/0P2A3CD fyoqa6VmjOr60s3QM2Zvr4KlGt8bcpvzbEmI8G96gbCsSTIm2JICl52hAHl+2yzBEqka wcKA== 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=iqN95fCRo90wR5HZi4ifvniYqCQzOtwsukcrrY3Xsmo=; b=N8b7xGzLuj66tbQNA42S6/oP4B3TjqW951J7r08PAoIIi4RD9Q6TxccuJdfDKtESC9 ZFmKm3Nqfz5/CkmXDUsdMJDu9pxsnbzwXSOE1i1qUwCwgUdMNqvktgeE9xF6NNwUwyRv mao+6cCMuWp0dYjgxRdZ9GSzo426ODcOIHhnBA+TNe0b7q1TtfVw8bNj3qxpgswBHmfu edvKZslYPjfVR41DYhtJhLLkWBHQ5XqVOtTjd0/Yq5xY20SGPj5wDbX+k8mPAzpWEofs 1f8bk6dfzM/r+7HMK2dp8ZywRLAqSsJKZeUPl4MrRWidmz1CBbp7++Cf9FmiNn3R5rRR n2+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NPmnYLYL; 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 60-20020a9d0ec2000000b00617082d9b26si10389115otj.1.2022.07.19.05.33.47; Tue, 19 Jul 2022 05:34:01 -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=NPmnYLYL; 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 S239659AbiGSM1J (ORCPT + 99 others); Tue, 19 Jul 2022 08:27:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237241AbiGSMY4 (ORCPT ); Tue, 19 Jul 2022 08:24:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8317D5071E; Tue, 19 Jul 2022 05:09:48 -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 306EEB81B32; Tue, 19 Jul 2022 12:09:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81BB6C36AE5; Tue, 19 Jul 2022 12:09:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232550; bh=hPEDbcvAPKZfOqkxksytzGutu2Ale869Ev1r8RuDN8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NPmnYLYLxNabr/MVQKjUuQW0kryQhNSZgi2ScT/oFdKu18bAT+x++DBHwPTAm/fKo QXIshbO68YpUVAnBQcUiaQp9rHA5QgaTT+wHyJC/QzSPdAuC2Lg4AuD2SgSawwrKi2 RVz26R8HkOYL5+cmO25c/w6fZQza3gWzrpGgpmyQ= 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.10 063/112] nexthop: Fix data-races around nexthop_compat_mode. Date: Tue, 19 Jul 2022 13:53:56 +0200 Message-Id: <20220719114632.594100958@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114626.156073229@linuxfoundation.org> References: <20220719114626.156073229@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.8 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 bdf00bf24bef9be1ca641a6390fd5487873e0d2e ] While reading nexthop_compat_mode, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 4f80116d3df3 ("net: ipv4: add sysctl for nexthop api compatibility mode") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/fib_semantics.c | 2 +- net/ipv4/nexthop.c | 5 +++-- net/ipv6/route.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -1831,7 +1831,7 @@ int fib_dump_info(struct sk_buff *skb, u goto nla_put_failure; if (nexthop_is_blackhole(fi->nh)) rtm->rtm_type = RTN_BLACKHOLE; - if (!fi->fib_net->ipv4.sysctl_nexthop_compat_mode) + if (!READ_ONCE(fi->fib_net->ipv4.sysctl_nexthop_compat_mode)) goto offload; } --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -882,7 +882,7 @@ static void __remove_nexthop_fib(struct /* __ip6_del_rt does a release, so do a hold here */ fib6_info_hold(f6i); ipv6_stub->ip6_del_rt(net, f6i, - !net->ipv4.sysctl_nexthop_compat_mode); + !READ_ONCE(net->ipv4.sysctl_nexthop_compat_mode)); } } @@ -1194,7 +1194,8 @@ out: if (!rc) { nh_base_seq_inc(net); nexthop_notify(RTM_NEWNEXTHOP, new_nh, &cfg->nlinfo); - if (replace_notify && net->ipv4.sysctl_nexthop_compat_mode) + if (replace_notify && + READ_ONCE(net->ipv4.sysctl_nexthop_compat_mode)) nexthop_replace_notify(net, new_nh, &cfg->nlinfo); } --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -5641,7 +5641,7 @@ static int rt6_fill_node(struct net *net if (nexthop_is_blackhole(rt->nh)) rtm->rtm_type = RTN_BLACKHOLE; - if (net->ipv4.sysctl_nexthop_compat_mode && + if (READ_ONCE(net->ipv4.sysctl_nexthop_compat_mode) && rt6_fill_node_nexthop(skb, rt->nh, &nh_flags) < 0) goto nla_put_failure;