]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: bcmgenet: Add a check for oversized packets
authorFlorian Fainelli <f.fainelli@gmail.com>
Fri, 27 Jan 2023 00:08:19 +0000 (16:08 -0800)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 14 Mar 2023 15:47:08 +0000 (16:47 +0100)
BugLink: https://bugs.launchpad.net/bugs/2011425
[ Upstream commit 5c0862c2c962052ed5055220a00ac1cefb92fbcd ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
drivers/net/ethernet/broadcom/genet/bcmgenet.c

index b70dea17f9d318ba048484871a97d1f50de39631..a3de08065eddc7dc4117158293a7584189be0718 100644 (file)
@@ -2316,6 +2316,14 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring,
                          __func__, p_index, ring->c_index,
                          ring->read_ptr, dma_length_status);
 
+               if (unlikely(len > RX_BUF_LENGTH)) {
+                       netif_err(priv, rx_status, dev, "oversized packet\n");
+                       dev->stats.rx_length_errors++;
+                       dev->stats.rx_errors++;
+                       dev_kfree_skb_any(skb);
+                       goto next;
+               }
+
                if (unlikely(!(dma_flag & DMA_EOP) || !(dma_flag & DMA_SOP))) {
                        netif_err(priv, rx_status, dev,
                                  "dropping fragmented packet!\n");