aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/vxlan.c
diff options
context:
space:
mode:
authorXin Long <lucien.xin@gmail.com>2019-10-29 01:24:32 +0800
committerDavid S. Miller <davem@davemloft.net>2019-10-29 17:39:26 -0700
commiteadf52cf1852196a1363044dcda22fa5d7f296f7 (patch)
treea8905a9be405f6f988683a689ac62df2c96fc618 /drivers/net/vxlan.c
parenterspan: fix the tun_info options_len check for erspan (diff)
downloadlinux-dev-eadf52cf1852196a1363044dcda22fa5d7f296f7.tar.xz
linux-dev-eadf52cf1852196a1363044dcda22fa5d7f296f7.zip
vxlan: check tun_info options_len properly
This patch is to improve the tun_info options_len by dropping the skb when TUNNEL_VXLAN_OPT is set but options_len is less than vxlan_metadata. This can void a potential out-of-bounds access on ip_tun_info. Fixes: ee122c79d422 ("vxlan: Flow based tunneling") Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/vxlan.c')
-rw-r--r--drivers/net/vxlan.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index fcf028220bca..ac5c597aa703 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2487,9 +2487,11 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
vni = tunnel_id_to_key32(info->key.tun_id);
ifindex = 0;
dst_cache = &info->dst_cache;
- if (info->options_len &&
- info->key.tun_flags & TUNNEL_VXLAN_OPT)
+ if (info->key.tun_flags & TUNNEL_VXLAN_OPT) {
+ if (info->options_len < sizeof(*md))
+ goto drop;
md = ip_tunnel_info_opts(info);
+ }
ttl = info->key.ttl;
tos = info->key.tos;
label = info->key.label;