From patchwork Sun Jul 11 09:56:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 12369065 X-Patchwork-Delegate: kuba@kernel.org 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 BAB9CC07E9E for ; Sun, 11 Jul 2021 09:58:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A075961279 for ; Sun, 11 Jul 2021 09:58:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232084AbhGKKAv (ORCPT ); Sun, 11 Jul 2021 06:00:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232024AbhGKKAu (ORCPT ); Sun, 11 Jul 2021 06:00:50 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6406C0613E5 for ; Sun, 11 Jul 2021 02:58:03 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id u8-20020a7bcb080000b02901e44e9caa2aso9247455wmj.4 for ; Sun, 11 Jul 2021 02:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pLzFV9bVvdr4KYBirs5X2mj4DUo8QQJaXp8K6ahEWRc=; b=Y2HnxZE9uISH43M340AOZ5mIqJD9tWGUhE68UhwL5YsyErc23G25PBlgG2ZDFdrqO+ zQvXelHcRrwzaMKgoRQTYrOe/Zbgc5xWWOtjitlCxiVXQTV9mR9PhLvkpznLLte/hZ7t aGeMcAUvRjXnP552wFKcFI4hkyoR/0AicsmPs4nOLZ9mSwlI8OPWp+AQroaSDaeTsr9c QmzPBqHQYahnIyxUPKKtM8P1EnhXJEeR5smsWWbJvKBaPRn2Yd+3zowbFIgc47bwfPsa 8DT8b94QLKevyQvHkav+/nUKuiSUzdYlv7mheI2AR1VpagAnnBmzGSvDp127ZRq4oHrM +d6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pLzFV9bVvdr4KYBirs5X2mj4DUo8QQJaXp8K6ahEWRc=; b=hX59ImxVRPLBYmBHCw4rIZrKZLg2kFWgY+65b3Z6anqMi3MZcrLTumTKVrjdVDG2LO Q4p7o/PDiRkx4kwvxU7dxbNKnChXEakn+EVUlPjn4yO9PKm8NKSzgwUJqdON/zbT2gfB czOSdoHPLtwLfvTR2rJLjXLwc2y5sW2mjktU228uZQF7tL3Lfn94PDaA3v6yBij3Hy/T 6nMpU6wcrTQ23wOv3FjmsIYxxy5ASLZcfKjQeDO8EF3u8fx3gZF5JldgXyrerCdmZ+Tk 22p3MzQ1CBP2IzfQ/1e6rk36sh9jh2KIfR7VJY4uphr7zSln5A9eA2lcvxC3ZL65Qbst v0/Q== X-Gm-Message-State: AOAM533KRdj3hmyVHfcVobkcLVc7dA1Ia5MjZPBZ1GME8yJmxEEE66k3 h9iLHgBo21HG0nDr2qeQyfy6a3xMivFSywcSVcQ= X-Google-Smtp-Source: ABdhPJyalwUZFSHhyZ4Lc8XVzGNjSWk8JzjA5IhRBFMi881bU4Pz4wujoBnDe/4bLHXjEUJ+Jcs3rQ== X-Received: by 2002:a1c:7308:: with SMTP id d8mr19627179wmb.20.1625997482179; Sun, 11 Jul 2021 02:58:02 -0700 (PDT) Received: from debil.vdiclient.nvidia.com (84-238-136-197.ip.btc-net.bg. [84.238.136.197]) by smtp.gmail.com with ESMTPSA id m18sm9095567wmq.45.2021.07.11.02.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 02:58:01 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: stable@vger.kernel.org, roopa@nvidia.com, bridge@lists.linux-foundation.org, Nikolay Aleksandrov Subject: [PATCH net 1/2] net: bridge: multicast: fix PIM hello router port marking race Date: Sun, 11 Jul 2021 12:56:28 +0300 Message-Id: <20210711095629.2986949-2-razor@blackwall.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210711095629.2986949-1-razor@blackwall.org> References: <20210711095629.2986949-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Nikolay Aleksandrov When a PIM hello packet is received on a bridge port with multicast snooping enabled, we mark it as a router port automatically, that includes adding that port the router port list. The multicast lock protects that list, but it is not acquired in the PIM message case leading to a race condition, we need to take it to fix the race. Cc: stable@vger.kernel.org Fixes: 91b02d3d133b ("bridge: mcast: add router port on PIM hello message") Signed-off-by: Nikolay Aleksandrov --- net/bridge/br_multicast.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index 53c3a9d80d9c..3bbbc6d7b7c3 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -3264,7 +3264,9 @@ static void br_multicast_pim(struct net_bridge *br, pim_hdr_type(pimhdr) != PIM_TYPE_HELLO) return; + spin_lock(&br->multicast_lock); br_ip4_multicast_mark_router(br, port); + spin_unlock(&br->multicast_lock); } static int br_ip4_multicast_mrd_rcv(struct net_bridge *br, From patchwork Sun Jul 11 09:56:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 12369067 X-Patchwork-Delegate: kuba@kernel.org 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 E59BDC11F67 for ; Sun, 11 Jul 2021 09:58:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C946B61279 for ; Sun, 11 Jul 2021 09:58:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232106AbhGKKAw (ORCPT ); Sun, 11 Jul 2021 06:00:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232087AbhGKKAv (ORCPT ); Sun, 11 Jul 2021 06:00:51 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF4E9C0613E5 for ; Sun, 11 Jul 2021 02:58:04 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id n33so9195674wms.1 for ; Sun, 11 Jul 2021 02:58:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m+ppdXaepSm57DIGWDBCLlBbyDz4JtRjsnYacqgtWjM=; b=fnQhTuQfvikn8wsBlfQW8wa3TbTUdvL0BRKK1SsYvIwdDSwNo5zRHUXHIZiOrK1j0E DyOKpo7teKbeuC/1PSB5SYfWmdurOnmS2ML5Z3ywee1IsWq5zt134nq8CTF6o2Wpgagk vECivnNM30xVlMiDEndXTNjjyh24f6Uzcd5NrEZJRcUg4/anj/GxVspV+dI7IWBqik86 utcc1VgQn9CSpmE3l212ly279r+QKBnk+8jfqmMAgn+bx31+Mus5OX/xNlcarV+grdl5 Q+InIy7uEBcuh9LioRmh5VeBkXK1vglUBKECuZ3uu5JdQ8W2jW1QLLuft4wHStY4mr7Y b+MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m+ppdXaepSm57DIGWDBCLlBbyDz4JtRjsnYacqgtWjM=; b=JKFOBK0KbJ8RrfcExfZdYsLONYHC+0VVLCrbkRB4hM2/m+zRVcD72+Av4P54ZHctgB ONZC9QyjvQFI3BH4HCJKi8O5iy0mXZ5khipr6Y/TooayRAExD1y8b1oowadnzvHWqwdr bAjfS/K//py4WwbuIADv7if9djk/RAwP+fFac7Cw8U9M4QgljXvnaHkbxtmahzEN16eN RCTj3JzBBGVKNLpLeFLLTWzov2Ss9QSEhVkRfE8k9Gtuc6aYkkDPMispPKWnf1t8bQt5 n7iCefvGQQ7DzP6/A5BrgrY5mPrzJuxWX550gnIZitkGHdLIxfincqegBukbgfLrgcuV e08g== X-Gm-Message-State: AOAM531zCWwU/S/2Lhzop3OtI9OY3+CWSAPahvOuLgIigz+7zFewpak3 Ivszlc3nTMlzbvLRIh9h3G1SKVBb1jP96oPK+bw= X-Google-Smtp-Source: ABdhPJxMh5N/ZT1NO0GnZgOu0FK2DLpUQFpXk8FKrgs6M75XgwrtwyhH5hhkTruYNbSlG7vuXVK94A== X-Received: by 2002:a1c:7314:: with SMTP id d20mr48433637wmb.167.1625997483257; Sun, 11 Jul 2021 02:58:03 -0700 (PDT) Received: from debil.vdiclient.nvidia.com (84-238-136-197.ip.btc-net.bg. [84.238.136.197]) by smtp.gmail.com with ESMTPSA id m18sm9095567wmq.45.2021.07.11.02.58.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 02:58:02 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: stable@vger.kernel.org, roopa@nvidia.com, bridge@lists.linux-foundation.org, Nikolay Aleksandrov , linus.luessing@c0d3.blue Subject: [PATCH net 2/2] net: bridge: multicast: fix MRD advertisement router port marking race Date: Sun, 11 Jul 2021 12:56:29 +0300 Message-Id: <20210711095629.2986949-3-razor@blackwall.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210711095629.2986949-1-razor@blackwall.org> References: <20210711095629.2986949-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Nikolay Aleksandrov 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 --- net/bridge/br_multicast.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index 3bbbc6d7b7c3..d0434dc8c03b 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -3277,7 +3277,9 @@ static int br_ip4_multicast_mrd_rcv(struct net_bridge *br, igmp_hdr(skb)->type != IGMP_MRDISC_ADV) return -ENOMSG; + spin_lock(&br->multicast_lock); br_ip4_multicast_mark_router(br, port); + spin_unlock(&br->multicast_lock); return 0; } @@ -3345,7 +3347,9 @@ static void br_ip6_multicast_mrd_rcv(struct net_bridge *br, if (icmp6_hdr(skb)->icmp6_type != ICMPV6_MRDISC_ADV) return; + spin_lock(&br->multicast_lock); br_ip6_multicast_mark_router(br, port); + spin_unlock(&br->multicast_lock); } static int br_multicast_ipv6_rcv(struct net_bridge *br,