Skip to contentSkip to conversation

ip6_tunnel: fix ip6_tnl_lookup

PATCH In review Vadim Fedorenko 2 participants 2 messages Oct 11, 2016 – Oct 14, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ip6_tunnel: fix ip6_tnl_lookup

The commit ea3dc9601bda ("ip6_tunnel: Add support for wildcard tunnel endpoints.") introduces support for wildcards in tunnels endpoints, but in some rare circumstances ip6_tnl_lookup selects wrong tunnel interface relying only on source or destination address of the packet and not checking presence of wildcard in tunnels endpoints. Later in ip6_tnl_rcv this packets can be dicarded because of difference in ipproto even if fallback device have proper ipproto configuration.

This patch adds checks of wildcard endpoint in tunnel avoiding such behavior

Fixes ea3dc9601bda ("ip6_tunnel: Add support for wildcard tunnel

endpoints.")

---
 net/ipv6/ip6_tunnel.c | 2 ++
 1 file changed, 2 insertions(+)
net/ipv6/ip6_tunnel.c +2 -0
index 6a66adb..5692d6b 100644
@@ -157,6 +157,7 @@ ip6_tnl_lookup(struct net *net, const struct in6_addr *remote, const struct in6_
 	hash = HASH(&any, local);
 	for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) {
 		if (ipv6_addr_equal(local, &t->parms.laddr) &&
+		    ipv6_addr_any(&t->parms.raddr) &&
 		    (t->dev->flags & IFF_UP))
 			return t;
 	}
@@ -164,6 +165,7 @@ ip6_tnl_lookup(struct net *net, const struct in6_addr *remote, const struct in6_
 	hash = HASH(remote, &any);
 	for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) {
 		if (ipv6_addr_equal(remote, &t->parms.raddr) &&
+		    ipv6_addr_any(&t->parms.laddr) &&
 		    (t->dev->flags & IFF_UP))
 			return t;
 	}
Signature · 1 line
1.9.1
maintainer
#1 lore raw

From: Vadim Fedorenko <[email protected]>
Date: Tue, 11 Oct 2016 22:47:20 +0300

Quoted 8 lines

The commit ea3dc9601bda ("ip6_tunnel: Add support for wildcard tunnel endpoints.") introduces support for wildcards in tunnels endpoints, but in some rare circumstances ip6_tnl_lookup selects wrong tunnel interface relying only on source or destination address of the packet and not checking presence of wildcard in tunnels endpoints. Later in ip6_tnl_rcv this packets can be dicarded because of difference in ipproto even if fallback device have proper ipproto configuration.

Quoted 7 lines

This patch adds checks of wildcard endpoint in tunnel avoiding such behavior

Fixes ea3dc9601bda ("ip6_tunnel: Add support for wildcard tunnel

endpoints.")

Applied and queued up for -stable.