Commit f1fb521f authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

ip_tunnel: Add missing validation of encap type to ip_tunnel_encap_setup()

The encap->type comes straight from Netlink. Validate it against
max supported encap types just like ip_encap_hlen() already does.

Fixes: a8c5f9 ("ip_tunnel: Ops registration for secondary encap (fou, gue)")
Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bb1553c8
...@@ -573,6 +573,9 @@ int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t, ...@@ -573,6 +573,9 @@ int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t,
if (t->encap.type == TUNNEL_ENCAP_NONE) if (t->encap.type == TUNNEL_ENCAP_NONE)
return 0; return 0;
if (t->encap.type >= MAX_IPTUN_ENCAP_OPS)
return -EINVAL;
rcu_read_lock(); rcu_read_lock();
ops = rcu_dereference(iptun_encaps[t->encap.type]); ops = rcu_dereference(iptun_encaps[t->encap.type]);
if (likely(ops && ops->build_header)) if (likely(ops && ops->build_header))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment