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

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

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
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -573,6 +573,9 @@ int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t,
	if (t->encap.type == TUNNEL_ENCAP_NONE)
		return 0;

	if (t->encap.type >= MAX_IPTUN_ENCAP_OPS)
		return -EINVAL;

	rcu_read_lock();
	ops = rcu_dereference(iptun_encaps[t->encap.type]);
	if (likely(ops && ops->build_header))