Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp479216imn; Wed, 27 Jul 2022 11:20:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vukvcuEGVmayDZhBZHN1cUr+kHowJ6oZC/C60Ad8OEDpLvKOlAk+O18OTLoQWXIBipuPWL X-Received: by 2002:a17:907:75f9:b0:72b:1438:474d with SMTP id jz25-20020a17090775f900b0072b1438474dmr18505389ejc.738.1658946042380; Wed, 27 Jul 2022 11:20:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946042; cv=none; d=google.com; s=arc-20160816; b=rRrslJ6KS55XeJ2VOOiMzfyqxsSWV8ogONozcbZLNKuHNbwaHESqjU7z5scmKPkku4 j+UEri54Bq1c7OeU+qGTFIs5GSGdQAIh8+/sO+qdPMuKnKTlB1PJgYMlaxjnz26t7Ef7 tD1IWmDuSf/DY38a+htaty3Ngl7msoPNtbgiuFizB6VDNW2qDSbrQV+ASoACF3j5iPzi AD6tui8+YM95qXU+oI6xtSu1oIfKq6oAg2An67CI2bdiH7UX6lQupOktUWJpVPFEaToj Xh2GOHx11eDmTKIUkdX7Sa1qGWGbHJRLXADgAE89HIkIdKPUM5lPZRRf9gmNmWlK5XBj 7pwQ== 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=vTaImZAPX+RmDOUBdCuQDj7RQPkuWCovMpZeXVJNTqo=; b=ZxElkYKGGYAGTOD6yKlr1Dp/ANc6fEWWtDSTRbQ6OUMvgVpP6Dg9pTrwx/lU6uusj9 a5W6hTYCNBkr/NtOQ1lD4/FQWhK56FXMgoOakvZnKk+lcQ97TpPn8Fs3KU+4QAmTuuFB 9MohZa0RS/pT6YPMDOmxW6L4veHo5RngxEEmrxAa69YeJzqfTBS18mqQyr7jo2cGGgzz /EpmvjxiRhDDXuqTv8XjZtI8aOHWnWUxvUwrVCiLR+RsQhjKe4OaS878MsM61pucJvDM /q5Mqy+aOZlbDGJw2pHixrq4lTb49MWNY3UOS2nv47nbn2MPiD67HARdIO254MwdmQhu Lchg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BkfUWDqh; 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 du6-20020a17090772c600b00711dc674239si17196696ejc.726.2022.07.27.11.20.16; Wed, 27 Jul 2022 11:20:42 -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=BkfUWDqh; 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 S239139AbiG0Qju (ORCPT + 99 others); Wed, 27 Jul 2022 12:39:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239341AbiG0QjM (ORCPT ); Wed, 27 Jul 2022 12:39:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 430105A17A; Wed, 27 Jul 2022 09:28:46 -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 04DC661A1B; Wed, 27 Jul 2022 16:28:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 123A2C433B5; Wed, 27 Jul 2022 16:28:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939325; bh=HRJLnCZvgqlS5n6E+XUwDVFty5BxsGXl+icR2zlYEhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BkfUWDqhdQySwzxQ2tY4NP94HIrK8mhExqAwdRBGiD7ez7yXVYTTET3Tx5lJXOlsI zzQUkMSNq6BasURo8vCwJryf4Ah0udxpYSu4eodJdFDNzT+O5pn/HhBFeenWZmxJM4 +6ezl99oAr72ca2LF95SjYp19vOGJseYFdV+xj+g= 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 30/87] igmp: Fix data-races around sysctl_igmp_llm_reports. Date: Wed, 27 Jul 2022 18:10:23 +0200 Message-Id: <20220727161010.264957270@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 f6da2267e71106474fbc0943dc24928b9cb79119 ] While reading sysctl_igmp_llm_reports, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. This test can be packed into a helper, so such changes will be in the follow-up series after net is merged into net-next. if (ipv4_is_local_multicast(pmc->multiaddr) && !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) Fixes: df2cf4a78e48 ("IGMP: Inhibit reports for local multicast groups") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/igmp.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index cac2fdd08df0..7cd444d75c3d 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c @@ -469,7 +469,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc, if (pmc->multiaddr == IGMP_ALL_HOSTS) return skb; - if (ipv4_is_local_multicast(pmc->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports) + if (ipv4_is_local_multicast(pmc->multiaddr) && + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) return skb; mtu = READ_ONCE(dev->mtu); @@ -595,7 +596,7 @@ static int igmpv3_send_report(struct in_device *in_dev, struct ip_mc_list *pmc) if (pmc->multiaddr == IGMP_ALL_HOSTS) continue; if (ipv4_is_local_multicast(pmc->multiaddr) && - !net->ipv4.sysctl_igmp_llm_reports) + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) continue; spin_lock_bh(&pmc->lock); if (pmc->sfcount[MCAST_EXCLUDE]) @@ -738,7 +739,8 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc, if (type == IGMPV3_HOST_MEMBERSHIP_REPORT) return igmpv3_send_report(in_dev, pmc); - if (ipv4_is_local_multicast(group) && !net->ipv4.sysctl_igmp_llm_reports) + if (ipv4_is_local_multicast(group) && + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) return 0; if (type == IGMP_HOST_LEAVE_MESSAGE) @@ -922,7 +924,8 @@ static bool igmp_heard_report(struct in_device *in_dev, __be32 group) if (group == IGMP_ALL_HOSTS) return false; - if (ipv4_is_local_multicast(group) && !net->ipv4.sysctl_igmp_llm_reports) + if (ipv4_is_local_multicast(group) && + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) return false; rcu_read_lock(); @@ -1047,7 +1050,7 @@ static bool igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb, if (im->multiaddr == IGMP_ALL_HOSTS) continue; if (ipv4_is_local_multicast(im->multiaddr) && - !net->ipv4.sysctl_igmp_llm_reports) + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) continue; spin_lock_bh(&im->lock); if (im->tm_running) @@ -1298,7 +1301,8 @@ static void __igmp_group_dropped(struct ip_mc_list *im, gfp_t gfp) #ifdef CONFIG_IP_MULTICAST if (im->multiaddr == IGMP_ALL_HOSTS) return; - if (ipv4_is_local_multicast(im->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports) + if (ipv4_is_local_multicast(im->multiaddr) && + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) return; reporter = im->reporter; @@ -1340,7 +1344,8 @@ static void igmp_group_added(struct ip_mc_list *im) #ifdef CONFIG_IP_MULTICAST if (im->multiaddr == IGMP_ALL_HOSTS) return; - if (ipv4_is_local_multicast(im->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports) + if (ipv4_is_local_multicast(im->multiaddr) && + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) return; if (in_dev->dead) @@ -1644,7 +1649,7 @@ static void ip_mc_rejoin_groups(struct in_device *in_dev) if (im->multiaddr == IGMP_ALL_HOSTS) continue; if (ipv4_is_local_multicast(im->multiaddr) && - !net->ipv4.sysctl_igmp_llm_reports) + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) continue; /* a failover is happening and switches -- 2.35.1