Skip to contentSkip to conversation

net: keep original skb which only needs header checking during software GSO

PATCH Superseded Jason Wang 2 participants 3 messages Sep 19, 2014

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH 1/1 net: keep original skb which only needs header checking during software GSO

Commit ce93718fb7cdbc064c3000ff59e4d3200bdfa744 ("net: Don't keep around original SKB when we software segment GSO frames") frees the original skb after software GSO even for dodgy gso skbs. This breaks the stream throughput from untrusted sources, since only header checking was done during software GSO instead of a true segmentation. This patch fixes this by freeing the original gso skb only when it was really segmented by software.

Fixes ce93718fb7cdbc064c3000ff59e4d3200bdfa744 ("net: Don't keep around original SKB when we software segment GSO frames.")

CC David S. Miller <[email protected]>
---
 net/core/dev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/core/dev.c +4 -2
index e916ba8..b7a0e1d 100644
@@ -2694,10 +2694,12 @@ struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device *dev)
 		struct sk_buff *segs;
 
 		segs = skb_gso_segment(skb, features);
-		kfree_skb(skb);
 		if (IS_ERR(segs))
 			segs = NULL;
-		skb = segs;
+		else if (segs) {
+			kfree_skb(skb);
+			skb = segs;
+		}
 	} else {
 		if (skb_needs_linearize(skb, features) &&
 		    __skb_linearize(skb))
Signature · 1 line
1.9.1
#1 lore raw
Quoted 26 lines · Jason Wang

Commit ce93718fb7cdbc064c3000ff59e4d3200bdfa744 ("net: Don't keep around original SKB when we software segment GSO frames") frees the original skb after software GSO even for dodgy gso skbs. This breaks the stream throughput from untrusted sources, since only header checking was done during software GSO instead of a true segmentation. This patch fixes this by freeing the original gso skb only when it was really segmented by software.

Fixes ce93718fb7cdbc064c3000ff59e4d3200bdfa744 ("net: Don't keep around original SKB when we software segment GSO frames.")

CC David S. Miller <[email protected]>
---
 net/core/dev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/core/dev.c +0 -1
index e916ba8..b7a0e1d 100644
@@ -2694,10 +2694,12 @@ struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device *dev)
 		struct sk_buff *segs;
 
 		segs = skb_gso_segment(skb, features);
-		kfree_skb(skb);

net/core/dev.c struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device *dev) · line 2705

Quoted 10 lines
net/core/dev.c +4 -1
 		if (IS_ERR(segs))
 
-		skb = segs;
+		else if (segs) {
+			kfree_skb(skb);
+			skb = segs;
+		}
 	} else {
 		if (skb_needs_linearize(skb, features) &&
 		    __skb_linearize(skb))

Good catch !

While we are at it, could you use consume_skb() instead of kfree_skb(), and add missing {} (CodingStyle) ?

if (IS_ERR(segs)) {
	segs = NULL;
} else if (segs) {
	consume_skb(skb);
	skb = segs;
}

Thanks !

author
#2 lore raw
Quoted 50 lines · Eric Dumazet
Quoted 26 lines · Jason Wang

Commit ce93718fb7cdbc064c3000ff59e4d3200bdfa744 ("net: Don't keep around original SKB when we software segment GSO frames") frees the original skb after software GSO even for dodgy gso skbs. This breaks the stream throughput from untrusted sources, since only header checking was done during software GSO instead of a true segmentation. This patch fixes this by freeing the original gso skb only when it was really segmented by software.

Fixes ce93718fb7cdbc064c3000ff59e4d3200bdfa744 ("net: Don't keep around original SKB when we software segment GSO frames.")

CC David S. Miller <[email protected]>
---
 net/core/dev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/core/dev.c +0 -1
index e916ba8..b7a0e1d 100644
@@ -2694,10 +2694,12 @@ struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device *dev)
 		struct sk_buff *segs;
 
 		segs = skb_gso_segment(skb, features);
-		kfree_skb(skb);

net/core/dev.c struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device *dev) · line 2705

Quoted 10 lines
net/core/dev.c +4 -1
 		if (IS_ERR(segs))
 
-		skb = segs;
+		else if (segs) {
+			kfree_skb(skb);
+			skb = segs;
+		}
 	} else {
 		if (skb_needs_linearize(skb, features) &&
 		    __skb_linearize(skb))

Good catch !

While we are at it, could you use consume_skb() instead of kfree_skb(), and add missing {} (CodingStyle) ?

if (IS_ERR(segs)) {
	segs = NULL;
} else if (segs) {
	consume_skb(skb);
	skb = segs;
}
Quoted 3 lines

Thanks !

Yes, it's better. Will do them in V2.