Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0c64eda authored by Xin Long's avatar Xin Long Committed by Greg Kroah-Hartman
Browse files

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: 1a66a836 ("gre: add collect_md mode to ERSPAN tunnel")
Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 41a230fe
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -592,6 +592,9 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev,
		truncate = true;
	}

	if (tun_info->options_len < sizeof(*md))
		goto err_free_rt;

	md = ip_tunnel_info_opts(tun_info);
	if (!md)
		goto err_free_rt;