Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3425793pxf; Mon, 29 Mar 2021 01:44:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzk0e6mbsRmmK2jCDFzbRjkPHtUd8Q+DR22FAHLH9rkLradDVL/CPdUCxQk4VuCoMrwJ9Fy X-Received: by 2002:a17:906:3b41:: with SMTP id h1mr26557822ejf.506.1617007452302; Mon, 29 Mar 2021 01:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007452; cv=none; d=google.com; s=arc-20160816; b=KMWS2G2xA1pTBD05DRZd2A8XsZRiYXoQU0zny+Z6It6vkdGn8Mqq47ZsFJFrwClNcn WDllEjpn+0oWKeiKgsJak6Q4NGnEv/1dahpt5y8jcyIOFUWNLyWTC24XwADdx4jPaBPY bx0wL8ZAzYpcUPfRFMl3uvSsKj7LL7LajxXV+II1gp6ulBG0ZtEQp+oDd5FUsnLbNxf9 uQfzLiqjvPscoZClGQWFu08mFOAC6F77K9XHLLkwccTl9QAHF4umqxotR1A9gUPw8rq6 aEqUP56IDr3aJ9gxKcH0WIWTehIlOUtd1qvjDKeOdXx/NuYk/CYomsNzntcb5YbWJc5I llUQ== 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=5fc6YoSozgS7iguWw0sAvlXIg6B0JOLqe68/ng6MejM=; b=lvLqCj6NeHPRa0ii45pMAVIwpfWX+05qFBp2Q0rX1BxU3qiBQc5AHTtsoFfdKhM8iR ijLshn0U5GzbAdehlWEsgsL0teYj/eYx5b/TTH27N6LBHdKyS1PduqfV+TF1YopvK0JR OK5XKs+j+Ja8Z3IIJf/R1OesXUIaAi9SISj6e75u39mYT9DMUZSXV/bzLafwoaItrkIo C00nVqKltrVTc4ck8X7icvM18FdoBx97+e73GPQu+adPD8MW3r+HFU290f5mCO4DQsJ3 kx7utGZkGv4FUxWZMNi0yKQ10mgeMxQbnCkEnaCSrtePUedRpMEvnFixhluuJAScxCCj UG3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Gn5YU7EW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs6si12420345edb.145.2021.03.29.01.43.50; Mon, 29 Mar 2021 01:44:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Gn5YU7EW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S235287AbhC2Imi (ORCPT + 99 others); Mon, 29 Mar 2021 04:42:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:42442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232904AbhC2IYX (ORCPT ); Mon, 29 Mar 2021 04:24:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ED00E619C2; Mon, 29 Mar 2021 08:24:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006260; bh=9IfONxfl7zOM+uNS+hW2gVz03E0r6Wo4qXb85vEd4j4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gn5YU7EWaoR4KqLjv1OcjQ7w1TWj7S5XqHKnv/XNuzve1/VanT9+52FLiUh6T8pkU 9/JAL3sGdfsxoaBjoFL+yZrfv1s3w/tkGgwZscI/7OulJAtdOKVFPio9xzcpIWbekM v7k/9KhW88W1UxmPZzJHFlzm4y+u94VlBTSbKPz0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 175/221] net: bridge: dont notify switchdev for local FDB addresses Date: Mon, 29 Mar 2021 09:58:26 +0200 Message-Id: <20210329075634.986056008@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean [ Upstream commit 6ab4c3117aec4e08007d9e971fa4133e1de1082d ] As explained in this discussion: https://lore.kernel.org/netdev/20210117193009.io3nungdwuzmo5f7@skbuf/ the switchdev notifiers for FDB entries managed to have a zero-day bug. The bridge would not say that this entry is local: ip link add br0 type bridge ip link set swp0 master br0 bridge fdb add dev swp0 00:01:02:03:04:05 master local and the switchdev driver would be more than happy to offload it as a normal static FDB entry. This is despite the fact that 'local' and non-'local' entries have completely opposite directions: a local entry is locally terminated and not forwarded, whereas a static entry is forwarded and not locally terminated. So, for example, DSA would install this entry on swp0 instead of installing it on the CPU port as it should. There is an even sadder part, which is that the 'local' flag is implicit if 'static' is not specified, meaning that this command produces the same result of adding a 'local' entry: bridge fdb add dev swp0 00:01:02:03:04:05 master I've updated the man pages for 'bridge', and after reading it now, it should be pretty clear to any user that the commands above were broken and should have never resulted in the 00:01:02:03:04:05 address being forwarded (this behavior is coherent with non-switchdev interfaces): https://patchwork.kernel.org/project/netdevbpf/cover/20210211104502.2081443-1-olteanv@gmail.com/ If you're a user reading this and this is what you want, just use: bridge fdb add dev swp0 00:01:02:03:04:05 master static Because switchdev should have given drivers the means from day one to classify FDB entries as local/non-local, but didn't, it means that all drivers are currently broken. So we can just as well omit the switchdev notifications for local FDB entries, which is exactly what this patch does to close the bug in stable trees. For further development work where drivers might want to trap the local FDB entries to the host, we can add a 'bool is_local' to br_switchdev_fdb_call_notifiers(), and selectively make drivers act upon that bit, while all the others ignore those entries if the 'is_local' bit is set. Fixes: 6b26b51b1d13 ("net: bridge: Add support for notifying devices about FDB add/del") Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/bridge/br_switchdev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c index 015209bf44aa..3c42095fa75f 100644 --- a/net/bridge/br_switchdev.c +++ b/net/bridge/br_switchdev.c @@ -123,6 +123,8 @@ br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type) { if (!fdb->dst) return; + if (test_bit(BR_FDB_LOCAL, &fdb->flags)) + return; switch (type) { case RTM_DELNEIGH: -- 2.30.1