Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3054426rwe; Mon, 29 Aug 2022 05:12:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR7QF4i3/IA5rLm4Grpb/yUsV0XNHcTmrXaobIkCjwUB9iJ5WLgHTLuQ4ayguJOr/gmp+9Sf X-Received: by 2002:a17:902:76cb:b0:170:9f15:b9a1 with SMTP id j11-20020a17090276cb00b001709f15b9a1mr16258906plt.95.1661775177857; Mon, 29 Aug 2022 05:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661775177; cv=none; d=google.com; s=arc-20160816; b=KmYbqFMibDuRr5jAKSb0fnaCOj/OK99UGGudDl3SRXG5yhzF7tD0TdxdVUk2of1zVV 1y24uVEziAsZYLOj3hGrawwoASR6Nrta6uZ7Et16mChU/IA3a2sCQU3fJomfpK5MRg9G xG0jbUJodpTLQog+wtClghOwGpP8ByhxMeToUp1BpCVQ64F5a9m2m58S3flIMgOh4Cyn 1Knq+klfGORJ1QIluIgDnb3I9eZQ+hFyd7GnrOoPdQ3zFLnXKKM5dTOhJvzUZuXqajq4 /cK1nn72fgPvt2a6s0DFuvyLgrcRxY2RlAsjHbB+yg6cjfj08Xwm5BWPAcRCiWZBz+z6 F6kQ== 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=T63eTbhgiz5U/zk3tPjenXQl0ucO3vE9I5hzqxJQITo=; b=BI0mJLS4vi00zcTRMm03hgNZYH6ZlBo82XjH8eMUxVyKbvxJV1OyJi7MuLM80wVQ8i xf9SEYweM4vn9nFExltOpqbpETrrrsJ3F/rYB/7mf5wa34ymSzt8O+O8bsviEA9pGeW1 o8gUxoiDtBSZDklZxXLCrQ8F+yBq+lcdCIZ9oCn5S4jQ30XFBdlon055a9WZPltr2lK8 qB8i6aZicaWATLBENi/dOyDrfFtYmILa69vGXBjuPa2Kb3b788bt1ASUrhi0CfVicrN0 63ymkHBqO0p+o4ps1TDqSBN84eM/gKsBC1JsHlYNlbm6rQd0KeoJ4T+z2Qb+E+IiJNvw dxoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jZQPWXiN; 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 200-20020a6304d1000000b0042aa381f44fsi10570210pge.516.2022.08.29.05.12.46; Mon, 29 Aug 2022 05:12:57 -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=jZQPWXiN; 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 S232579AbiH2Lci (ORCPT + 99 others); Mon, 29 Aug 2022 07:32:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232717AbiH2L3p (ORCPT ); Mon, 29 Aug 2022 07:29:45 -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 CD1E57B2BE; Mon, 29 Aug 2022 04:18:04 -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 B32F561202; Mon, 29 Aug 2022 11:17:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5D19C433D6; Mon, 29 Aug 2022 11:17:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771860; bh=6EKBDqc52IalgZq0HP2UlKus3oH3wi8p+iN3Nd5JAPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jZQPWXiNdNjVx0OLdD+yUMkuRfIngHYt+Wbz8bMIUwgDLNNNHQWbJtUmMLeOPuLcZ UEZ12B3KyXNvk896tIXrTM2q4l03r2nqWmneA2IQxY+s5+3ytwsOWck1jpjS3fQTRz U5XSME9RJebNMckHoIWzwco8AJz6aMffjUgkBrcI= 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.19 077/158] net: Fix data-races around sysctl_fb_tunnels_only_for_init_net. Date: Mon, 29 Aug 2022 12:58:47 +0200 Message-Id: <20220829105812.263072308@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105808.828227973@linuxfoundation.org> References: <20220829105808.828227973@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 2563d30736e9a..78dd63a5c7c80 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -640,9 +640,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