cdddbcf14ee9cb4611c0d75e673837fa3c9997c8
[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 --- a/net/dsa/switch.c
37 +++ b/net/dsa/switch.c
38 @@ -180,9 +180,11 @@ static int dsa_switch_bridge_leave(struc
39 info->sw_index, info->port,
40 info->br);
41
42 - err = dsa_switch_sync_vlan_filtering(ds, info);
43 - if (err)
44 - return err;
45 + if (ds->dst->index == info->tree_index && ds->index == info->sw_index) {
46 + err = dsa_switch_sync_vlan_filtering(ds, info);
47 + if (err)
48 + return err;
49 + }
50
51 return dsa_tag_8021q_bridge_leave(ds, info);
52 }