All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: erspan: a couple fixes
@ 2017-12-15 22:27 William Tu
  2017-12-15 22:27 ` [PATCH net-next 1/2] net: erspan: fix wrong return value William Tu
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: William Tu @ 2017-12-15 22:27 UTC (permalink / raw)
  To: netdev

Haishuang Yan reports a couple of issues (wrong return value, 
pskb_may_pull) on erspan V1.  Since erspan V2 is in net-next,
this series fix the similar issues on v2.

William Tu (2):
  net: erspan: fix wrong return value
  net: erspan: reload pointer after pskb_may_pull

 net/ipv4/ip_gre.c  | 6 ++++--
 net/ipv6/ip6_gre.c | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

-- 
2.7.4

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

* [PATCH net-next 1/2] net: erspan: fix wrong return value
  2017-12-15 22:27 [PATCH net-next 0/2] net: erspan: a couple fixes William Tu
@ 2017-12-15 22:27 ` William Tu
  2017-12-16  7:33   ` 严海双
  2017-12-15 22:27 ` [PATCH net-next 2/2] net: erspan: reload pointer after pskb_may_pull William Tu
  2017-12-18 20:12 ` [PATCH net-next 0/2] net: erspan: a couple fixes David Miller
  2 siblings, 1 reply; 5+ messages in thread
From: William Tu @ 2017-12-15 22:27 UTC (permalink / raw)
  To: netdev; +Cc: Haishuang Yan

If pskb_may_pull return failed, return PACKET_REJECT
instead of -ENOMEM.

Fixes: 94d7d8f29287 ("ip6_gre: add erspan v2 support")
Fixes: f551c91de262 ("net: erspan: introduce erspan v2 for ip_gre")
Signed-off-by: William Tu <u9012063@gmail.com>
Cc: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
 net/ipv4/ip_gre.c  | 2 +-
 net/ipv6/ip6_gre.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 004800b923c6..1ca7451ff898 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -287,7 +287,7 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 	if (tunnel) {
 		len = gre_hdr_len + erspan_hdr_len(ver);
 		if (unlikely(!pskb_may_pull(skb, len)))
-			return -ENOMEM;
+			return PACKET_REJECT;
 
 		if (__iptunnel_pull_header(skb,
 					   len,
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 5c9c65f1d5c2..b3e4e0384f36 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -524,7 +524,7 @@ static int ip6erspan_rcv(struct sk_buff *skb, int gre_hdr_len,
 		int len = erspan_hdr_len(ver);
 
 		if (unlikely(!pskb_may_pull(skb, len)))
-			return -ENOMEM;
+			return PACKET_REJECT;
 
 		if (__iptunnel_pull_header(skb, len,
 					   htons(ETH_P_TEB),
-- 
2.7.4

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

* [PATCH net-next 2/2] net: erspan: reload pointer after pskb_may_pull
  2017-12-15 22:27 [PATCH net-next 0/2] net: erspan: a couple fixes William Tu
  2017-12-15 22:27 ` [PATCH net-next 1/2] net: erspan: fix wrong return value William Tu
@ 2017-12-15 22:27 ` William Tu
  2017-12-18 20:12 ` [PATCH net-next 0/2] net: erspan: a couple fixes David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: William Tu @ 2017-12-15 22:27 UTC (permalink / raw)
  To: netdev; +Cc: Haishuang Yan

pskb_may_pull() can change skb->data, so we need to re-load pkt_md
and ershdr at the right place.

Fixes: 94d7d8f29287 ("ip6_gre: add erspan v2 support")
Fixes: f551c91de262 ("net: erspan: introduce erspan v2 for ip_gre")
Signed-off-by: William Tu <u9012063@gmail.com>
Cc: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
 net/ipv4/ip_gre.c  | 4 +++-
 net/ipv6/ip6_gre.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 1ca7451ff898..02a34098afb0 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -279,7 +279,6 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 	 * Use ERSPAN 10-bit session ID as key.
 	 */
 	tpi->key = cpu_to_be32(ntohs(ershdr->session_id) & ID_MASK);
-	pkt_md = (struct erspan_metadata *)(ershdr + 1);
 	tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex,
 				  tpi->flags | TUNNEL_KEY,
 				  iph->saddr, iph->daddr, tpi->key);
@@ -289,6 +288,9 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 		if (unlikely(!pskb_may_pull(skb, len)))
 			return PACKET_REJECT;
 
+		ershdr = (struct erspan_base_hdr *)(skb->data + gre_hdr_len);
+		pkt_md = (struct erspan_metadata *)(ershdr + 1);
+
 		if (__iptunnel_pull_header(skb,
 					   len,
 					   htons(ETH_P_TEB),
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index b3e4e0384f36..87b9892dfa23 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -515,7 +515,6 @@ static int ip6erspan_rcv(struct sk_buff *skb, int gre_hdr_len,
 
 	ver = (ntohs(ershdr->ver_vlan) & VER_MASK) >> VER_OFFSET;
 	tpi->key = cpu_to_be32(ntohs(ershdr->session_id) & ID_MASK);
-	pkt_md = (struct erspan_metadata *)(ershdr + 1);
 
 	tunnel = ip6gre_tunnel_lookup(skb->dev,
 				      &ipv6h->saddr, &ipv6h->daddr, tpi->key,
@@ -526,6 +525,9 @@ static int ip6erspan_rcv(struct sk_buff *skb, int gre_hdr_len,
 		if (unlikely(!pskb_may_pull(skb, len)))
 			return PACKET_REJECT;
 
+		ershdr = (struct erspan_base_hdr *)skb->data;
+		pkt_md = (struct erspan_metadata *)(ershdr + 1);
+
 		if (__iptunnel_pull_header(skb, len,
 					   htons(ETH_P_TEB),
 					   false, false) < 0)
-- 
2.7.4

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

* Re: [PATCH net-next 1/2] net: erspan: fix wrong return value
  2017-12-15 22:27 ` [PATCH net-next 1/2] net: erspan: fix wrong return value William Tu
@ 2017-12-16  7:33   ` 严海双
  0 siblings, 0 replies; 5+ messages in thread
From: 严海双 @ 2017-12-16  7:33 UTC (permalink / raw)
  To: William Tu; +Cc: netdev



> On 2017年12月16日, at 上午6:27, William Tu <u9012063@gmail.com> wrote:
> 
> If pskb_may_pull return failed, return PACKET_REJECT
> instead of -ENOMEM.
> 
> Fixes: 94d7d8f29287 ("ip6_gre: add erspan v2 support")
> Fixes: f551c91de262 ("net: erspan: introduce erspan v2 for ip_gre")
> Signed-off-by: William Tu <u9012063@gmail.com>
> Cc: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>

Acked-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>

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

* Re: [PATCH net-next 0/2] net: erspan: a couple fixes
  2017-12-15 22:27 [PATCH net-next 0/2] net: erspan: a couple fixes William Tu
  2017-12-15 22:27 ` [PATCH net-next 1/2] net: erspan: fix wrong return value William Tu
  2017-12-15 22:27 ` [PATCH net-next 2/2] net: erspan: reload pointer after pskb_may_pull William Tu
@ 2017-12-18 20:12 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2017-12-18 20:12 UTC (permalink / raw)
  To: u9012063; +Cc: netdev

From: William Tu <u9012063@gmail.com>
Date: Fri, 15 Dec 2017 14:27:42 -0800

> Haishuang Yan reports a couple of issues (wrong return value, 
> pskb_may_pull) on erspan V1.  Since erspan V2 is in net-next,
> this series fix the similar issues on v2.

Series applied, thank you.

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

end of thread, other threads:[~2017-12-18 20:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-15 22:27 [PATCH net-next 0/2] net: erspan: a couple fixes William Tu
2017-12-15 22:27 ` [PATCH net-next 1/2] net: erspan: fix wrong return value William Tu
2017-12-16  7:33   ` 严海双
2017-12-15 22:27 ` [PATCH net-next 2/2] net: erspan: reload pointer after pskb_may_pull William Tu
2017-12-18 20:12 ` [PATCH net-next 0/2] net: erspan: a couple fixes David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.