diff options
author | David S. Miller <davem@davemloft.net> | 2017-12-18 15:11:26 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-12-18 15:11:26 -0500 |
commit | 0dc6905a6a99cc3f09de7e7b008c52d37c0a273f (patch) | |
tree | dedc322d3566dac8300b68c3fda955a61006ab58 | |
parent | 814a17841325643e2d08984d076f976a0b423872 (diff) | |
parent | d91e8db5b629a3c8c81db4dc317a66c7b5591821 (diff) | |
download | linux-0dc6905a6a99cc3f09de7e7b008c52d37c0a273f.tar.bz2 |
Merge branch 'erspan-a-couple-fixes'
William Tu says:
====================
net: erspan: a couple fixes
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.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/ip_gre.c | 6 | ||||
-rw-r--r-- | net/ipv6/ip6_gre.c | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 9a80d84fc182..fd4d6e96da7e 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); @@ -287,7 +286,10 @@ 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; + + ershdr = (struct erspan_base_hdr *)(skb->data + gre_hdr_len); + pkt_md = (struct erspan_metadata *)(ershdr + 1); if (__iptunnel_pull_header(skb, len, diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index 5c9c65f1d5c2..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, @@ -524,7 +523,10 @@ 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; + + ershdr = (struct erspan_base_hdr *)skb->data; + pkt_md = (struct erspan_metadata *)(ershdr + 1); if (__iptunnel_pull_header(skb, len, htons(ETH_P_TEB), |