From patchwork Mon Jul 19 14:49:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 480701 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 610D5C64E62 for ; Mon, 19 Jul 2021 16:08:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4FCB66128E for ; Mon, 19 Jul 2021 16:08:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345558AbhGSP1l (ORCPT ); Mon, 19 Jul 2021 11:27:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:39206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348221AbhGSPYj (ORCPT ); Mon, 19 Jul 2021 11:24:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EFF1F61456; Mon, 19 Jul 2021 16:03:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710597; bh=jCT26X888WcBIdKNcDNO9R0A1V4zgmbY4LfCssXov4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UJ+oIPZ4wYeC8f1vLqdpC0cMTPXcSmh6TxTs4nGvdqDB9TU2dBCxuYthazNJvyT5J jCKwDEnsDp4ba/s7pJhMVK8rmGGOtSudi2qrwLTrqy0oez7YSYZtGsF2vvpCcPDH2a Uz152ZYgbb9m2X39E3e8lKVN2i0/gK1KerLpOYdY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, linus.luessing@c0d3.blue, Nikolay Aleksandrov , "David S. Miller" Subject: [PATCH 5.13 038/351] net: bridge: multicast: fix MRD advertisement router port marking race Date: Mon, 19 Jul 2021 16:49:44 +0200 Message-Id: <20210719144945.793424215@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144944.537151528@linuxfoundation.org> References: <20210719144944.537151528@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Nikolay Aleksandrov commit 000b7287b67555fee39d39fff75229dedde0dcbf upstream. When an MRD advertisement is received on a bridge port with multicast snooping enabled, we mark it as a router port automatically, that includes adding that port to the router port list. The multicast lock protects that list, but it is not acquired in the MRD advertisement case leading to a race condition, we need to take it to fix the race. Cc: stable@vger.kernel.org Cc: linus.luessing@c0d3.blue Fixes: 4b3087c7e37f ("bridge: Snoop Multicast Router Advertisements") Signed-off-by: Nikolay Aleksandrov Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/bridge/br_multicast.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -3100,7 +3100,9 @@ static int br_ip4_multicast_mrd_rcv(stru igmp_hdr(skb)->type != IGMP_MRDISC_ADV) return -ENOMSG; + spin_lock(&br->multicast_lock); br_multicast_mark_router(br, port); + spin_unlock(&br->multicast_lock); return 0; } @@ -3168,7 +3170,9 @@ static void br_ip6_multicast_mrd_rcv(str if (icmp6_hdr(skb)->icmp6_type != ICMPV6_MRDISC_ADV) return; + spin_lock(&br->multicast_lock); br_multicast_mark_router(br, port); + spin_unlock(&br->multicast_lock); } static int br_multicast_ipv6_rcv(struct net_bridge *br,