netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] net: Validate size of non-TSO packets in validate_xmit_skb().
@ 2019-02-26 10:56 Michael Chan
  2019-02-26 15:16 ` Eric Dumazet
  2019-02-26 17:13 ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Chan @ 2019-02-26 10:56 UTC (permalink / raw)
  To: davem, maheshb, edumazet; +Cc: dja, netdev

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.

Separately, we should add a length check in validate_xmit_skb()
to drop these oversize packets before they reach the driver.
This patch only validates non-TSO packets.  Complete validation
of segmented TSO packet size will probably be too slow.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 net/core/dev.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index 5d03889..50c5174 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3373,6 +3373,13 @@ static struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device
 		}
 	}
 
+	if (!skb_is_gso(skb) &&
+	    skb->len > (dev->mtu + dev->hard_header_len + VLAN_HLEN)) {
+		net_warn_ratelimited("%s(): Dropping %d bytes oversize skb.\n",
+				     __func__, skb->len);
+		goto out_kfree_skb;
+	}
+
 	skb = validate_xmit_xfrm(skb, features, again);
 
 	return skb;
-- 
2.5.1


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

end of thread, other threads:[~2019-02-26 21:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-26 10:56 [PATCH RFC] net: Validate size of non-TSO packets in validate_xmit_skb() Michael Chan
2019-02-26 15:16 ` Eric Dumazet
2019-02-26 17:13 ` David Miller
2019-02-26 18:22   ` Michael Chan
2019-02-26 21:16     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).