diff mbox series

[v2,net-next] ip6_gre: fix a pontential issue in ip6erspan_rcv

Message ID 1513391125-28227-1-git-send-email-yanhaishuang@cmss.chinamobile.com
State Changes Requested, archived
Delegated to: David Miller
Headers show
Series [v2,net-next] ip6_gre: fix a pontential issue in ip6erspan_rcv | expand

Commit Message

Haishuang Yan Dec. 16, 2017, 2:25 a.m. UTC
pskb_may_pull() can change skb->data, so we need to load ipv6h/ershdr at
the right place.

Fixes: 5a963eb61b7c ("ip6_gre: Add ERSPAN native tunnel support")
Acked-by: William Tu <u9012063@gmail.com>
Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>

---
Change since v2:
  * Rebase on latest master.
---
 net/ipv6/ip6_gre.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

David Miller Dec. 19, 2017, 3:34 p.m. UTC | #1
From: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Date: Sat, 16 Dec 2017 10:25:25 +0800

> pskb_may_pull() can change skb->data, so we need to load ipv6h/ershdr at
> the right place.
> 
> Fixes: 5a963eb61b7c ("ip6_gre: Add ERSPAN native tunnel support")
> Acked-by: William Tu <u9012063@gmail.com>
> Cc: William Tu <u9012063@gmail.com>
> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>

This patch does not apply:

> +	ipv6h = ipv6_hdr(skb);
> +	ershdr = (struct erspan_base_hdr *)skb->data;
>  	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);

There is not "pkt_md = ..." assignment in net-next on this line.
Haishuang Yan Dec. 20, 2017, 1:27 a.m. UTC | #2
> On 2017年12月19日, at 下午11:34, David Miller <davem@davemloft.net> wrote:
> 
> From: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
> Date: Sat, 16 Dec 2017 10:25:25 +0800
> 
>> pskb_may_pull() can change skb->data, so we need to load ipv6h/ershdr at
>> the right place.
>> 
>> Fixes: 5a963eb61b7c ("ip6_gre: Add ERSPAN native tunnel support")
>> Acked-by: William Tu <u9012063@gmail.com>
>> Cc: William Tu <u9012063@gmail.com>
>> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
> 
> This patch does not apply:
> 
>> +	ipv6h = ipv6_hdr(skb);
>> +	ershdr = (struct erspan_base_hdr *)skb->data;
>> 	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);
> 
> There is not "pkt_md = ..." assignment in net-next on this line.
> 

Okay, I will fix it and resubmit another commit, thanks.
diff mbox series

Patch

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index f210f9c..aa1512e 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -507,12 +507,11 @@  static int ip6erspan_rcv(struct sk_buff *skb, int gre_hdr_len,
 	struct ip6_tnl *tunnel;
 	u8 ver;
 
-	ipv6h = ipv6_hdr(skb);
-	ershdr = (struct erspan_base_hdr *)skb->data;
-
 	if (unlikely(!pskb_may_pull(skb, sizeof(*ershdr))))
 		return PACKET_REJECT;
 
+	ipv6h = ipv6_hdr(skb);
+	ershdr = (struct erspan_base_hdr *)skb->data;
 	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);