Skip to contentSkip to conversation

net: Validate size of non-TSO packets in validate_xmit_skb().

RFC PATCH In review Michael Chan 3 participants 5 messages Feb 26, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 net: Validate size of non-TSO packets in validate_xmit_skb().

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 <[email protected]> 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.

---
 net/core/dev.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/core/dev.c +7 -0
index 5d03889..50c5174 100644
@@ -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;
Signature · 1 line
2.5.1
#1 lore raw
Quoted 9 lines · Michael Chan

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 <[email protected]> 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.

Why ?

We keep adding checks in the 'fast path' and make slower and slower after each release.

We need to fix the root cause really.

Quoted 27 lines

This patch only validates non-TSO packets. Complete validation of segmented TSO packet size will probably be too slow.

---
 net/core/dev.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/core/dev.c +7 -0
index 5d03889..50c5174 100644
@@ -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;
maintainer
#2 lore raw
In reply to Michael Chan

From: Michael Chan <[email protected]>
Date: Tue, 26 Feb 2019 05:56:41 -0500

Quoted 7 lines

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 <[email protected]> to fix the issue.

Quoted 6 lines

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.

Anything which changes the dst of an SKB really is responsible for fixing up whatever became "incompatible" in the new path.

So like Eric I want to see this out of the fast path.

#3 lore raw
Quoted 16 lines · David Miller

From: Michael Chan <[email protected]>
Date: Tue, 26 Feb 2019 05:56:41 -0500

Quoted 12 lines

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 <[email protected]> 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.

Quoted 6 lines
Quoted 1 line

Anything which changes the dst of an SKB really is responsible for fixing up whatever became "incompatible" in the new path.

So like Eric I want to see this out of the fast path.

Ok. In the meantime, will you take a 2-line bnxt_en patch that will prevent this issue in kernel 5.0?

maintainer
#4 lore raw

From: Michael Chan <[email protected]>
Date: Tue, 26 Feb 2019 10:22:42 -0800

Quoted 19 lines · David Miller
Quoted 18 lines

From: Michael Chan <[email protected]>
Date: Tue, 26 Feb 2019 05:56:41 -0500

Quoted 13 lines

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 <[email protected]> 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.

Quoted 7 lines
Quoted 4 lines

Anything which changes the dst of an SKB really is responsible for fixing up whatever became "incompatible" in the new path.

So like Eric I want to see this out of the fast path.

Ok. In the meantime, will you take a 2-line bnxt_en patch that will prevent this issue in kernel 5.0?

Sure, but we will have to remember to remove it when it is no longer necessary...