]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.15.17/net-dsa-discard-frames-from-unused-ports.patch
Linux 4.14.95
[thirdparty/kernel/stable-queue.git] / releases / 4.15.17 / net-dsa-discard-frames-from-unused-ports.patch
CommitLineData
1d0a9062
GKH
1From foo@baz Tue Apr 10 23:19:36 CEST 2018
2From: Andrew Lunn <andrew@lunn.ch>
3Date: Sat, 7 Apr 2018 20:37:40 +0200
4Subject: net: dsa: Discard frames from unused ports
5
6From: Andrew Lunn <andrew@lunn.ch>
7
8
9[ Upstream commit fc5f33768cca7144f8d793205b229d46740d183b ]
10
11The Marvell switches under some conditions will pass a frame to the
12host with the port being the CPU port. Such frames are invalid, and
13should be dropped. Not dropping them can result in a crash when
14incrementing the receive statistics for an invalid port.
15
16Reported-by: Chris Healy <cphealy@gmail.com>
17Fixes: 91da11f870f0 ("net: Distributed Switch Architecture protocol support")
18Signed-off-by: Andrew Lunn <andrew@lunn.ch>
19Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
20Signed-off-by: David S. Miller <davem@davemloft.net>
21Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22---
23 net/dsa/dsa_priv.h | 8 +++++++-
24 1 file changed, 7 insertions(+), 1 deletion(-)
25
26--- a/net/dsa/dsa_priv.h
27+++ b/net/dsa/dsa_priv.h
28@@ -117,6 +117,7 @@ static inline struct net_device *dsa_mas
29 struct dsa_port *cpu_dp = dev->dsa_ptr;
30 struct dsa_switch_tree *dst = cpu_dp->dst;
31 struct dsa_switch *ds;
32+ struct dsa_port *slave_port;
33
34 if (device < 0 || device >= DSA_MAX_SWITCHES)
35 return NULL;
36@@ -128,7 +129,12 @@ static inline struct net_device *dsa_mas
37 if (port < 0 || port >= ds->num_ports)
38 return NULL;
39
40- return ds->ports[port].slave;
41+ slave_port = &ds->ports[port];
42+
43+ if (unlikely(slave_port->type != DSA_PORT_TYPE_USER))
44+ return NULL;
45+
46+ return slave_port->slave;
47 }
48
49 /* port.c */