erspan: fix the tun_info options_len check for erspan
authorXin Long <lucien.xin@gmail.com>
Mon, 28 Oct 2019 15:19:35 +0000 (23:19 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 10 Nov 2019 10:25:36 +0000 (11:25 +0100)
commitb0c64eda9996479c9b135c23f5b18a0314af4a98
treeb7dfb7b7818a5eb42b009a070ff9a32397458cd2
parent41a230fef787315d982dd915ef2a33a136e9a1d5
erspan: fix the tun_info options_len check for erspan

[ Upstream commit 2eb8d6d2910cfe3dc67dc056f26f3dd9c63d47cd ]

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ipv4/ip_gre.c