Skip to content

Commit 7fb2b53

Browse files
Michael Changregkh
authored andcommitted
bnxt_en: Drop oversize TX packets to prevent errors.
[ Upstream commit 2b3c688 ] There have been reports of oversize UDP packets being sent to the driver to be transmitted, causing error conditions. The issue is likely caused by the dst of the SKB switching between 'lo' with 64K MTU and the hardware device with a smaller MTU. Patches are being proposed by Mahesh Bandewar <maheshb@google.com> to fix the issue. In the meantime, add a quick length check in the driver to prevent the error. The driver uses the TX packet size as index to look up an array to setup the TX BD. The array is large enough to support all MTU sizes supported by the driver. The oversize TX packet causes the driver to index beyond the array and put garbage values into the TX BD. Add a simple check to prevent this. Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7e7a271 commit 7fb2b53

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • drivers/net/ethernet/broadcom/bnxt

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,12 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
330330
}
331331

332332
length >>= 9;
333+
if (unlikely(length >= ARRAY_SIZE(bnxt_lhint_arr))) {
334+
dev_warn_ratelimited(&pdev->dev, "Dropped oversize %d bytes TX packet.\n",
335+
skb->len);
336+
i = 0;
337+
goto tx_dma_error;
338+
}
333339
flags |= bnxt_lhint_arr[length];
334340
txbd->tx_bd_len_flags_type = cpu_to_le32(flags);
335341

0 commit comments

Comments
 (0)