079ac7eb63b7b5545032fa793f2beec4cdcb7e14
[openwrt/openwrt.git] /
1 From 108dc8741c203e9d6ce4e973367f1bac20c7192b Mon Sep 17 00:00:00 2001
2 From: Tobias Waldekranz <tobias@waldekranz.com>
3 Date: Mon, 24 Jan 2022 22:09:44 +0100
4 Subject: net: dsa: Avoid cross-chip syncing of VLAN filtering
5
6 Changes to VLAN filtering are not applicable to cross-chip
7 notifications.
8
9 On a system like this:
10
11 .-----. .-----. .-----.
12 | sw1 +---+ sw2 +---+ sw3 |
13 '-1-2-' '-1-2-' '-1-2-'
14
15 Before this change, upon sw1p1 leaving a bridge, a call to
16 dsa_port_vlan_filtering would also be made to sw2p1 and sw3p1.
17
18 In this scenario:
19
20 .---------. .-----. .-----.
21 | sw1 +---+ sw2 +---+ sw3 |
22 '-1-2-3-4-' '-1-2-' '-1-2-'
23
24 When sw1p4 would leave a bridge, dsa_port_vlan_filtering would be
25 called for sw2 and sw3 with a non-existing port - leading to array
26 out-of-bounds accesses and crashes on mv88e6xxx.
27
28 Fixes: d371b7c92d19 ("net: dsa: Unset vlan_filtering when ports leave the bridge")
29 Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
30 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
31 Signed-off-by: David S. Miller <davem@davemloft.net>
32 ---
33 net/dsa/switch.c | 8 +++++---
34 1 file changed, 5 insertions(+), 3 deletions(-)
35
36 diff --git a/net/dsa/switch.c b/net/dsa/switch.c
37 index 9f9b70d6070a3..517cc83d13cc8 100644
38 --- a/net/dsa/switch.c
39 +++ b/net/dsa/switch.c
40 @@ -180,9 +180,11 @@ static int dsa_switch_bridge_leave(struct dsa_switch *ds,
41 info->sw_index, info->port,
42 info->bridge);
43
44 - err = dsa_switch_sync_vlan_filtering(ds, info);
45 - if (err)
46 - return err;
47 + if (ds->dst->index == info->tree_index && ds->index == info->sw_index) {
48 + err = dsa_switch_sync_vlan_filtering(ds, info);
49 + if (err)
50 + return err;
51 + }
52
53 return dsa_tag_8021q_bridge_leave(ds, info);
54 }
55 --
56 cgit