aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/ip6_gre.c
diff options
context:
space:
mode:
authorXin Long <lucien.xin@gmail.com>2019-10-28 23:19:35 +0800
committerDavid S. Miller <davem@davemloft.net>2019-10-29 17:36:42 -0700
commit2eb8d6d2910cfe3dc67dc056f26f3dd9c63d47cd (patch)
tree5490ad73490d3235a4da373fe744a0a9f8087951 /net/ipv6/ip6_gre.c
parentnet: hisilicon: Fix ping latency when deal with high throughput (diff)
downloadlinux-dev-2eb8d6d2910cfe3dc67dc056f26f3dd9c63d47cd.tar.xz
linux-dev-2eb8d6d2910cfe3dc67dc056f26f3dd9c63d47cd.zip
erspan: fix the tun_info options_len check for erspan
The check for !md doens't really work for ip_tunnel_info_opts(info) which only does info + 1. Also to avoid out-of-bounds access on info, it should ensure options_len is not less than erspan_metadata in both erspan_xmit() and ip6erspan_tunnel_xmit(). Fixes: 1a66a836da ("gre: add collect_md mode to ERSPAN tunnel") Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to '')
-rw-r--r--net/ipv6/ip6_gre.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 787d9f2a6e99..923034c52ce4 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -980,9 +980,9 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
dsfield = key->tos;
if (!(tun_info->key.tun_flags & TUNNEL_ERSPAN_OPT))
goto tx_err;
- md = ip_tunnel_info_opts(tun_info);
- if (!md)
+ if (tun_info->options_len < sizeof(*md))
goto tx_err;
+ md = ip_tunnel_info_opts(tun_info);
tun_id = tunnel_id_to_key32(key->tun_id);
if (md->version == 1) {