Skip to contentSkip to conversation

net/core: move vlan_depth out of while loop in skb_network_protocol()

PATCH Applied [email protected] 3 participants 3 messages Mar 12, 2013

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

PATCH 1/1 net/core: move vlan_depth out of while loop in skb_network_protocol()

From: Li RongQing <[email protected]>

move vlan_depth out of while loop, or else vlan_depth always is ETH_HLEN, can not be increased, and lead to infinite loop when frame has two vlan headers.

---
 net/core/dev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -1
index 90cee5b..35a6a6e 100644
@@ -2211,9 +2211,9 @@ EXPORT_SYMBOL(skb_checksum_help);
 __be16 skb_network_protocol(struct sk_buff *skb)
 {
 	__be16 type = skb->protocol;
+	int vlan_depth = ETH_HLEN;
 
 	while (type == htons(ETH_P_8021Q)) {
-		int vlan_depth = ETH_HLEN;
 		struct vlan_hdr *vh;
 
 		if (unlikely(!pskb_may_pull(skb, vlan_depth + VLAN_HLEN)))
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 15 lines · On Tue, 2013-03-12 at 14:30 +0800, [email protected] wrote:

From: Li RongQing <[email protected]>

move vlan_depth out of while loop, or else vlan_depth always is ETH_HLEN, can not be increased, and lead to infinite loop when frame has two vlan headers.

---
 net/core/dev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +0 -0
index 90cee5b..35a6a6e 100644

net/core/dev.c EXPORT_SYMBOL(skb_checksum_help); · line 2219

Quoted 10 lines
net/core/dev.c +1 -1
@@ -2211,9 +2211,9 @@ EXPORT_SYMBOL(skb_checksum_help);
 __be16 skb_network_protocol(struct sk_buff *skb)
 {
 	__be16 type = skb->protocol;
+	int vlan_depth = ETH_HLEN;
 
 	while (type == htons(ETH_P_8021Q)) {
-		int vlan_depth = ETH_HLEN;
 		struct vlan_hdr *vh;
 
 		if (unlikely(!pskb_may_pull(skb, vlan_depth + VLAN_HLEN)))

Nice catch, bug added in commit 05e8ef4ab2d8087d (net: factor out skb_mac_gso_segment() from skb_gso_segment() )

So this is a patch for net tree, not for net-next.

maintainer Applied
#2 lore raw

From: Eric Dumazet <[email protected]>
Date: Tue, 12 Mar 2013 07:56:26 +0100

Quoted 25 lines · On Tue, 2013-03-12 at 14:30 +0800, [email protected] wrote:
Quoted 24 lines

From: Li RongQing <[email protected]>

move vlan_depth out of while loop, or else vlan_depth always is ETH_HLEN, can not be increased, and lead to infinite loop when frame has two vlan headers.

---
 net/core/dev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -1
index 90cee5b..35a6a6e 100644
@@ -2211,9 +2211,9 @@ EXPORT_SYMBOL(skb_checksum_help);
 __be16 skb_network_protocol(struct sk_buff *skb)
 {
 	__be16 type = skb->protocol;
+	int vlan_depth = ETH_HLEN;
 
 	while (type == htons(ETH_P_8021Q)) {
-		int vlan_depth = ETH_HLEN;
 		struct vlan_hdr *vh;
 
Quoted 8 lines

net/core/dev.c EXPORT_SYMBOL(skb_checksum_help); · line 2219

Quoted 1 line
net/core/dev.c +0 -0
 		if (unlikely(!pskb_may_pull(skb, vlan_depth + VLAN_HLEN)))

Nice catch, bug added in commit 05e8ef4ab2d8087d (net: factor out skb_mac_gso_segment() from skb_gso_segment() )

So this is a patch for net tree, not for net-next.

Applied, thanks.