Skip to content

Commit 3059370

Browse files
lunngregkh
authored andcommitted
net: dsa: Discard frames from unused ports
commit fc5f337 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: Chris Healy <[email protected]> Fixes: 91da11f ("net: Distributed Switch Architecture protocol support") Signed-off-by: Andrew Lunn <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 90a32d1 commit 3059370

File tree

8 files changed

+24
-0
lines changed

8 files changed

+24
-0
lines changed

net/dsa/tag_brcm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev,
121121
if (source_port >= ds->num_ports || !ds->ports[source_port].netdev)
122122
return NULL;
123123

124+
if (unlikely(ds->cpu_port_mask & BIT(source_port)))
125+
return NULL;
126+
124127
/* Remove Broadcom tag and update checksum */
125128
skb_pull_rcsum(skb, BRCM_TAG_LEN);
126129

net/dsa/tag_dsa.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ static struct sk_buff *dsa_rcv(struct sk_buff *skb, struct net_device *dev,
107107
if (source_port >= ds->num_ports || !ds->ports[source_port].netdev)
108108
return NULL;
109109

110+
if (unlikely(ds->cpu_port_mask & BIT(source_port)))
111+
return NULL;
112+
110113
/*
111114
* Convert the DSA header to an 802.1q header if the 'tagged'
112115
* bit in the DSA header is set. If the 'tagged' bit is clear,

net/dsa/tag_edsa.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev,
120120
if (source_port >= ds->num_ports || !ds->ports[source_port].netdev)
121121
return NULL;
122122

123+
if (unlikely(ds->cpu_port_mask & BIT(source_port)))
124+
return NULL;
125+
123126
/*
124127
* If the 'tagged' bit is set, convert the DSA tag to a 802.1q
125128
* tag and delete the ethertype part. If the 'tagged' bit is

net/dsa/tag_ksz.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ static struct sk_buff *ksz_rcv(struct sk_buff *skb, struct net_device *dev,
9292
if (source_port >= ds->num_ports || !ds->ports[source_port].netdev)
9393
return NULL;
9494

95+
if (unlikely(ds->cpu_port_mask & BIT(source_port)))
96+
return NULL;
97+
9598
pskb_trim_rcsum(skb, skb->len - KSZ_EGRESS_TAG_LEN);
9699

97100
skb->dev = ds->ports[source_port].netdev;

net/dsa/tag_lan9303.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev,
108108
return NULL;
109109
}
110110

111+
if (unlikely(ds->cpu_port_mask & BIT(source_port)))
112+
return NULL;
113+
111114
if (!ds->ports[source_port].netdev) {
112115
dev_warn_ratelimited(&dev->dev, "Dropping packet due to invalid netdev or device\n");
113116
return NULL;

net/dsa/tag_mtk.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev,
8181
if (!ds->ports[port].netdev)
8282
return NULL;
8383

84+
if (unlikely(ds->cpu_port_mask & BIT(port)))
85+
return NULL;
86+
8487
skb->dev = ds->ports[port].netdev;
8588

8689
return skb;

net/dsa/tag_qca.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev,
104104
if (!ds->ports[port].netdev)
105105
return NULL;
106106

107+
if (unlikely(ds->cpu_port_mask & BIT(port)))
108+
return NULL;
109+
107110
/* Update skb & forward the frame accordingly */
108111
skb->dev = ds->ports[port].netdev;
109112

net/dsa/tag_trailer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ static struct sk_buff *trailer_rcv(struct sk_buff *skb, struct net_device *dev,
7676
if (source_port >= ds->num_ports || !ds->ports[source_port].netdev)
7777
return NULL;
7878

79+
if (unlikely(ds->cpu_port_mask & BIT(source_port)))
80+
return NULL;
81+
7982
pskb_trim_rcsum(skb, skb->len - 4);
8083

8184
skb->dev = ds->ports[source_port].netdev;

0 commit comments

Comments
 (0)