Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3075171rwe; Mon, 29 Aug 2022 05:32:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR5oWnkLMwAwDAdmxg5WaNuVR1DK0+UbDJPfu/PPHCaGDqfntRr4ImvODV2JItApUEIG5VyC X-Received: by 2002:a17:903:245:b0:172:bf22:fc5 with SMTP id j5-20020a170903024500b00172bf220fc5mr16386842plh.101.1661776325513; Mon, 29 Aug 2022 05:32:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661776325; cv=none; d=google.com; s=arc-20160816; b=dm/9jl+PevKirORNMhXiGhe/MYNPSJdxyLgtTJSDpDvMRTO31Rceb/i4jhg/pp4lOQ pXy3H95ShZDmmCKj8SLYgUyPYrpk9BTchEAdShinDO3zhpV4v36R8oXwAOgvGlDtG4qH ZWINW4DiIYyojUTs/WVHDr3ruC5t1erWktq5ysQ7NQcrBUibZtHNmKCmcxkg1iBy4iJz /AhYynnCDWCmT+ZvWyvHZ/2AesYAhU+yevG8vvudqjSmtOjEE49o+LXL76xW2zFaiJMs sSEgQeA/uoNZWHvD11zEhNMG6UukNdjncJ0WqmMnL4+e2unU3dYqS3154tkLSmSp9KIQ qzyQ== 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=SVb7AZwd2WB/MgqFQhAUWyOISA8h44chJ4ZWM8zaHJs=; b=NGKKqkhY35W15K9ZoJivOr16D3dlMuvN+pfk9ednn80AF+gkUonBKclITEY0cuE9i6 9y+trvjoN8Mxkfa1RKtNufY+eMEeqfTmC/tDskbliX0P2gGRir7mo4SqV5Lq4OpYVIKl HaUZBhyoMKQ+SouEz80HQtuW2+++90Q5yvUm2guQZZPYTA2p42LUh1S9Y0htKlZP/CeB HDWrlLT6tdaWl4smfHT9lkGkLXmKFRkyl4tnv+o3BCvuvadQlvqoz1d1uBWakxRt1Lw2 VHSPWQ9z88lPuwZ43mx6Mv1O2+Taf3HiZHTam/Fge5KWNEqv/UO64dxKMjfxCicfV+Ri OLvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kLpJVgUJ; 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 r7-20020a6560c7000000b0041a4118f4fbsi9455648pgv.439.2022.08.29.05.31.52; Mon, 29 Aug 2022 05:32:05 -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=kLpJVgUJ; 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 S230171AbiH2LUH (ORCPT + 99 others); Mon, 29 Aug 2022 07:20:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231610AbiH2LSv (ORCPT ); Mon, 29 Aug 2022 07:18:51 -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 0C2DA74DDF; Mon, 29 Aug 2022 04:12:29 -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 BFB5B6122A; Mon, 29 Aug 2022 11:12:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D048DC433D6; Mon, 29 Aug 2022 11:12:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771522; bh=5R7n5eJOo3hqC+1Bq2Dda1+Gp6SZlShOP59hNraakAc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kLpJVgUJZEkZGeIEFy75JzkkhDjqSF86MbocIBDAUcnLZUwPc+EMSS5UxVA5fpOQ3 Dd8K0PlUyWbUGIjKYqLaeniwim1nKlCkj3udq+fz06CQmnWKG9EbKJcHUIurFNSs7X /Fp371z6m72ErjpVFTvZIVt3WuZV0Ga9okpjYFQg= 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 58/86] net: Fix data-races around sysctl_fb_tunnels_only_for_init_net. Date: Mon, 29 Aug 2022 12:59:24 +0200 Message-Id: <20220829105758.931939865@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105756.500128871@linuxfoundation.org> References: <20220829105756.500128871@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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,T_SCC_BODY_TEXT_LINE 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 af67508ea6cbf0e4ea27f8120056fa2efce127dd ] While reading sysctl_fb_tunnels_only_for_init_net, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 79134e6ce2c9 ("net: do not create fallback tunnels for non-default namespaces") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- include/linux/netdevice.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index ed2d531400051..c05701f89d6dd 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -633,9 +633,14 @@ extern int sysctl_devconf_inherit_init_net; */ static inline bool net_has_fallback_tunnels(const struct net *net) { - return !IS_ENABLED(CONFIG_SYSCTL) || - !sysctl_fb_tunnels_only_for_init_net || - (net == &init_net && sysctl_fb_tunnels_only_for_init_net == 1); +#if IS_ENABLED(CONFIG_SYSCTL) + int fb_tunnels_only_for_init_net = READ_ONCE(sysctl_fb_tunnels_only_for_init_net); + + return !fb_tunnels_only_for_init_net || + (net_eq(net, &init_net) && fb_tunnels_only_for_init_net == 1); +#else + return true; +#endif } static inline int netdev_queue_numa_node_read(const struct netdev_queue *q) -- 2.35.1