netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] net: skbuff: Remove errornous length validation in skb_vlan_pop()
@ 2016-09-19 15:53 Shmulik Ladkani
  2016-09-19 15:53 ` [PATCH v2 2/2] net: skbuff: Coding: Use eth_type_vlan() instead of open coding it Shmulik Ladkani
  2016-09-19 16:28 ` [PATCH v2 1/2] net: skbuff: Remove errornous length validation in skb_vlan_pop() Shmulik Ladkani
  0 siblings, 2 replies; 6+ messages in thread
From: Shmulik Ladkani @ 2016-09-19 15:53 UTC (permalink / raw)
  To: David S . Miller
  Cc: Jiri Pirko, Daniel Borkmann, netdev, Shmulik Ladkani,
	Pravin Shelar

In 93515d53b1
  "net: move vlan pop/push functions into common code"
skb_vlan_pop was moved from its private location in openvswitch to
skbuff common code.

In case !vlan_tx_tag_present, the original 'pop_vlan()' assured
that skb->len is sufficient (if skb->len < VLAN_ETH_HLEN then pop was a
no-op).

This validation was moved as is into the new common 'skb_vlan_pop'.

Alas, in its original location (openvswitch), there was a guarantee that
'data' points to the mac_header, therefore the 'skb->len < VLAN_ETH_HLEN'
condition made sense.
However there's no such guarantee in the generic 'skb_vlan_pop'.

For short packets received in rx path going through 'skb_vlan_pop',
this causes 'skb_vlan_pop' to fail pop-ing a valid vlan hdr (in the non
hw-accel case) or to fail moving next tag into hw-accel tag.

Remove the 'skb->len < VLAN_ETH_HLEN' condition entirely:
It is superfluous since inner '__skb_vlan_pop' already verifies there
are VLAN_ETH_HLEN writable bytes at the mac_header.

Fixes: 93515d53b1 ("net: move vlan pop/push functions into common code")
Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Cc: Pravin Shelar <pshelar@ovn.org>
---
 net/core/skbuff.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 1e329d4112..4dbaedb745 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4535,9 +4535,8 @@ int skb_vlan_pop(struct sk_buff *skb)
 	if (likely(skb_vlan_tag_present(skb))) {
 		skb->vlan_tci = 0;
 	} else {
-		if (unlikely((skb->protocol != htons(ETH_P_8021Q) &&
-			      skb->protocol != htons(ETH_P_8021AD)) ||
-			     skb->len < VLAN_ETH_HLEN))
+		if (unlikely(skb->protocol != htons(ETH_P_8021Q) &&
+			     skb->protocol != htons(ETH_P_8021AD)))
 			return 0;
 
 		err = __skb_vlan_pop(skb, &vlan_tci);
@@ -4545,9 +4544,8 @@ int skb_vlan_pop(struct sk_buff *skb)
 			return err;
 	}
 	/* move next vlan tag to hw accel tag */
-	if (likely((skb->protocol != htons(ETH_P_8021Q) &&
-		    skb->protocol != htons(ETH_P_8021AD)) ||
-		   skb->len < VLAN_ETH_HLEN))
+	if (likely(skb->protocol != htons(ETH_P_8021Q) &&
+		   skb->protocol != htons(ETH_P_8021AD)))
 		return 0;
 
 	vlan_proto = skb->protocol;
-- 
2.7.4

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

* [PATCH v2 2/2] net: skbuff: Coding: Use eth_type_vlan() instead of open coding it
  2016-09-19 15:53 [PATCH v2 1/2] net: skbuff: Remove errornous length validation in skb_vlan_pop() Shmulik Ladkani
@ 2016-09-19 15:53 ` Shmulik Ladkani
  2016-09-19 16:20   ` Eric Dumazet
  2016-09-19 16:28 ` [PATCH v2 1/2] net: skbuff: Remove errornous length validation in skb_vlan_pop() Shmulik Ladkani
  1 sibling, 1 reply; 6+ messages in thread
From: Shmulik Ladkani @ 2016-09-19 15:53 UTC (permalink / raw)
  To: David S . Miller; +Cc: Jiri Pirko, Daniel Borkmann, netdev, Shmulik Ladkani

Fix 'skb_vlan_pop' to use eth_type_vlan instead of directly comparing
skb->protocol to ETH_P_8021Q or ETH_P_8021AD.

Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
---
 net/core/skbuff.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 4dbaedb745..1369faa182 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4535,8 +4535,7 @@ int skb_vlan_pop(struct sk_buff *skb)
 	if (likely(skb_vlan_tag_present(skb))) {
 		skb->vlan_tci = 0;
 	} else {
-		if (unlikely(skb->protocol != htons(ETH_P_8021Q) &&
-			     skb->protocol != htons(ETH_P_8021AD)))
+		if (unlikely(!eth_type_vlan(skb->protocol)))
 			return 0;
 
 		err = __skb_vlan_pop(skb, &vlan_tci);
@@ -4544,8 +4543,7 @@ int skb_vlan_pop(struct sk_buff *skb)
 			return err;
 	}
 	/* move next vlan tag to hw accel tag */
-	if (likely(skb->protocol != htons(ETH_P_8021Q) &&
-		   skb->protocol != htons(ETH_P_8021AD)))
+	if (likely(!eth_type_vlan(skb->protocol)))
 		return 0;
 
 	vlan_proto = skb->protocol;
-- 
2.7.4

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

* Re: [PATCH v2 2/2] net: skbuff: Coding: Use eth_type_vlan() instead of open coding it
  2016-09-19 15:53 ` [PATCH v2 2/2] net: skbuff: Coding: Use eth_type_vlan() instead of open coding it Shmulik Ladkani
@ 2016-09-19 16:20   ` Eric Dumazet
  2016-09-19 16:23     ` Shmulik Ladkani
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Dumazet @ 2016-09-19 16:20 UTC (permalink / raw)
  To: Shmulik Ladkani; +Cc: David S . Miller, Jiri Pirko, Daniel Borkmann, netdev

On Mon, 2016-09-19 at 18:53 +0300, Shmulik Ladkani wrote:
> Fix 'skb_vlan_pop' to use eth_type_vlan instead of directly comparing
> skb->protocol to ETH_P_8021Q or ETH_P_8021AD.
> 
> Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
> ---

You forgot to explicitly state this was targeting net-next tree.

This is detailed in Documentation/networking/netdev-FAQ.tx

Q: How do I indicate which tree (net vs. net-next) my patch should be
in?

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

* Re: [PATCH v2 2/2] net: skbuff: Coding: Use eth_type_vlan() instead of open coding it
  2016-09-19 16:20   ` Eric Dumazet
@ 2016-09-19 16:23     ` Shmulik Ladkani
  2016-09-19 17:37       ` Eric Dumazet
  0 siblings, 1 reply; 6+ messages in thread
From: Shmulik Ladkani @ 2016-09-19 16:23 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David S . Miller, Jiri Pirko, Daniel Borkmann, netdev

On Mon, 19 Sep 2016 09:20:55 -0700 Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Mon, 2016-09-19 at 18:53 +0300, Shmulik Ladkani wrote:
> > Fix 'skb_vlan_pop' to use eth_type_vlan instead of directly comparing
> > skb->protocol to ETH_P_8021Q or ETH_P_8021AD.
> > 
> > Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
> > ---  
> 
> You forgot to explicitly state this was targeting net-next tree.

Thanks, was an oversight.
Requires resubmission?

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

* Re: [PATCH v2 1/2] net: skbuff: Remove errornous length validation in skb_vlan_pop()
  2016-09-19 15:53 [PATCH v2 1/2] net: skbuff: Remove errornous length validation in skb_vlan_pop() Shmulik Ladkani
  2016-09-19 15:53 ` [PATCH v2 2/2] net: skbuff: Coding: Use eth_type_vlan() instead of open coding it Shmulik Ladkani
@ 2016-09-19 16:28 ` Shmulik Ladkani
  1 sibling, 0 replies; 6+ messages in thread
From: Shmulik Ladkani @ 2016-09-19 16:28 UTC (permalink / raw)
  To: David S . Miller; +Cc: Jiri Pirko, Daniel Borkmann, netdev, Pravin Shelar

On Mon, 19 Sep 2016 18:53:19 +0300 Shmulik Ladkani <shmulik.ladkani@gmail.com> wrote:
> Remove the 'skb->len < VLAN_ETH_HLEN' condition entirely:
> It is superfluous since inner '__skb_vlan_pop' already verifies there
> are VLAN_ETH_HLEN writable bytes at the mac_header.

Please disregard, will send a v3.

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

* Re: [PATCH v2 2/2] net: skbuff: Coding: Use eth_type_vlan() instead of open coding it
  2016-09-19 16:23     ` Shmulik Ladkani
@ 2016-09-19 17:37       ` Eric Dumazet
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2016-09-19 17:37 UTC (permalink / raw)
  To: Shmulik Ladkani; +Cc: David S . Miller, Jiri Pirko, Daniel Borkmann, netdev

On Mon, 2016-09-19 at 19:23 +0300, Shmulik Ladkani wrote:
> On Mon, 19 Sep 2016 09:20:55 -0700 Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > On Mon, 2016-09-19 at 18:53 +0300, Shmulik Ladkani wrote:
> > > Fix 'skb_vlan_pop' to use eth_type_vlan instead of directly comparing
> > > skb->protocol to ETH_P_8021Q or ETH_P_8021AD.
> > > 
> > > Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
> > > ---  
> > 
> > You forgot to explicitly state this was targeting net-next tree.
> 
> Thanks, was an oversight.
> Requires resubmission?

I do not think so.

I only reminded it because it seems many netdev submissions
are forgetting this, and it does not help David Miller job.

Thanks

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

end of thread, other threads:[~2016-09-19 17:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-19 15:53 [PATCH v2 1/2] net: skbuff: Remove errornous length validation in skb_vlan_pop() Shmulik Ladkani
2016-09-19 15:53 ` [PATCH v2 2/2] net: skbuff: Coding: Use eth_type_vlan() instead of open coding it Shmulik Ladkani
2016-09-19 16:20   ` Eric Dumazet
2016-09-19 16:23     ` Shmulik Ladkani
2016-09-19 17:37       ` Eric Dumazet
2016-09-19 16:28 ` [PATCH v2 1/2] net: skbuff: Remove errornous length validation in skb_vlan_pop() Shmulik Ladkani

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).