Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30593709 authored by Andrew Lunn's avatar Andrew Lunn Committed by Greg Kroah-Hartman
Browse files

net: dsa: Discard frames from unused ports



commit fc5f33768cca7144f8d793205b229d46740d183b upstream.

The Marvell switches under some conditions will pass a frame to the
host with the port being the CPU port. Such frames are invalid, and
should be dropped. Not dropping them can result in a crash when
incrementing the receive statistics for an invalid port.

This has been reworked for 4.14, which does not have the central
dsa_master_find_slave() function, so each tag driver needs to check.

Reported-by: default avatarChris Healy <cphealy@gmail.com>
Fixes: 91da11f8 ("net: Distributed Switch Architecture protocol support")
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 90a32d1f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -121,6 +121,9 @@ static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev,
	if (source_port >= ds->num_ports || !ds->ports[source_port].netdev)
		return NULL;

	if (unlikely(ds->cpu_port_mask & BIT(source_port)))
		return NULL;

	/* Remove Broadcom tag and update checksum */
	skb_pull_rcsum(skb, BRCM_TAG_LEN);

+3 −0
Original line number Diff line number Diff line
@@ -107,6 +107,9 @@ static struct sk_buff *dsa_rcv(struct sk_buff *skb, struct net_device *dev,
	if (source_port >= ds->num_ports || !ds->ports[source_port].netdev)
		return NULL;

	if (unlikely(ds->cpu_port_mask & BIT(source_port)))
		return NULL;

	/*
	 * Convert the DSA header to an 802.1q header if the 'tagged'
	 * bit in the DSA header is set.  If the 'tagged' bit is clear,
+3 −0
Original line number Diff line number Diff line
@@ -120,6 +120,9 @@ static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev,
	if (source_port >= ds->num_ports || !ds->ports[source_port].netdev)
		return NULL;

	if (unlikely(ds->cpu_port_mask & BIT(source_port)))
		return NULL;

	/*
	 * If the 'tagged' bit is set, convert the DSA tag to a 802.1q
	 * tag and delete the ethertype part.  If the 'tagged' bit is
+3 −0
Original line number Diff line number Diff line
@@ -92,6 +92,9 @@ static struct sk_buff *ksz_rcv(struct sk_buff *skb, struct net_device *dev,
	if (source_port >= ds->num_ports || !ds->ports[source_port].netdev)
		return NULL;

	if (unlikely(ds->cpu_port_mask & BIT(source_port)))
		return NULL;

	pskb_trim_rcsum(skb, skb->len - KSZ_EGRESS_TAG_LEN);

	skb->dev = ds->ports[source_port].netdev;
+3 −0
Original line number Diff line number Diff line
@@ -108,6 +108,9 @@ static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev,
		return NULL;
	}

	if (unlikely(ds->cpu_port_mask & BIT(source_port)))
		return NULL;

	if (!ds->ports[source_port].netdev) {
		dev_warn_ratelimited(&dev->dev, "Dropping packet due to invalid netdev or device\n");
		return NULL;
Loading