Netdev List
 help / color / mirror / Atom feed
* [PATCH net] r8152: drop the tx packet with invalid length
@ 2014-11-26  9:56 Hayes Wang
  2014-11-26 16:52 ` Eric Dumazet
  0 siblings, 1 reply; 12+ messages in thread
From: Hayes Wang @ 2014-11-26  9:56 UTC (permalink / raw)
  To: netdev; +Cc: nic_swsd, linux-kernel, linux-usb, Hayes Wang

Drop the tx packet which is more than the size of agg_buf_sz. When
creating a bridge with the device, we may get the tx packet with
TSO and the length is more than the gso_max_size which is set by
the driver through netif_set_gso_max_size(). Such packets couldn't
be transmitted and should be dropped directly.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 drivers/net/usb/r8152.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index c6554c7..ebdaff7 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1897,6 +1897,15 @@ static netdev_tx_t rtl8152_start_xmit(struct sk_buff *skb,
 {
 	struct r8152 *tp = netdev_priv(netdev);
 
+	if ((skb->len + sizeof(struct tx_desc)) > agg_buf_sz) {
+		struct net_device_stats *stats = &netdev->stats;
+
+		dev_kfree_skb_any(skb);
+		stats->tx_dropped++;
+		WARN_ON_ONCE(1);
+		return NETDEV_TX_OK;
+	}
+
 	skb_tx_timestamp(skb);
 
 	skb_queue_tail(&tp->tx_queue, skb);
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-12-22 15:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-26  9:56 [PATCH net] r8152: drop the tx packet with invalid length Hayes Wang
2014-11-26 16:52 ` Eric Dumazet
2014-11-26 17:06   ` David Miller
2014-11-26 18:44     ` Eric Dumazet
2014-11-26 20:33       ` David Miller
2014-12-19  6:42         ` Hayes Wang
2014-12-19 17:36           ` Eric Dumazet
2014-12-19 18:13             ` Eric Dumazet
2014-12-22  2:22               ` Hayes Wang
2014-12-22 11:34               ` Hayes Wang
2014-12-22 15:21                 ` [PATCH net] net: ndo_gso_check() must force segmentation Eric Dumazet
2014-12-22 15:59                   ` Jesse Gross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox