net: systemport: Add a check for oversized packets
authorFlorian Fainelli <f.fainelli@gmail.com>
Thu, 28 May 2015 22:24:44 +0000 (15:24 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 31 May 2015 06:51:25 +0000 (23:51 -0700)
Occasionnaly we may get oversized packets from the hardware which exceed
the nomimal 2KiB buffer size we allocate SKBs with. Add an early check
which drops the packet to avoid invoking skb_over_panic() and move on to
processing the next packet.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bcmsysport.c

index d777b0db9e6388ce54f14e3e1942d4abdbbbbb4c..909ad7a0d48088fcaa8295dfdd3b3617becf8d12 100644 (file)
@@ -638,6 +638,14 @@ static unsigned int bcm_sysport_desc_rx(struct bcm_sysport_priv *priv,
                          p_index, priv->rx_c_index, priv->rx_read_ptr,
                          len, status);
 
+               if (unlikely(len > RX_BUF_LENGTH)) {
+                       netif_err(priv, rx_status, ndev, "oversized packet\n");
+                       ndev->stats.rx_length_errors++;
+                       ndev->stats.rx_errors++;
+                       dev_kfree_skb_any(skb);
+                       goto next;
+               }
+
                if (unlikely(!(status & DESC_EOP) || !(status & DESC_SOP))) {
                        netif_err(priv, rx_status, ndev, "fragmented packet!\n");
                        ndev->stats.rx_dropped++;