Skip to contentSkip to conversation

ipvs: do not use random local source address for tunnels

PATCH In review Julian Anastasov 2 participants 2 messages Jun 27, 2015 – Jun 29, 2015

Subsystems (3)
lore
Share & tools
lore

Julian Anastasov

author maintainer
#0 lore raw

PATCH 1/1 ipvs: do not use random local source address for tunnels

Michael Vallaly reports about wrong source address used in rare cases for tunneled traffic. Looks like __ip_vs_get_out_rt in 3.10+ is providing uninitialized dest_dst->dst_saddr.ip because ip_vs_dest_dst_alloc uses kmalloc. While we retry after seeing EINVAL from routing for data that does not look like valid local address, it still succeeded when this memory was previously used from other dests and with different local addresses. As result, we can use valid local address that is not suitable for our real server.

Fix it by providing 0.0.0.0 every time our cache is refreshed. By this way we will get preferred source address from routing.

Fixes 026ace060dfe ("ipvs: optimize dst usage for real server")
---
 net/netfilter/ipvs/ip_vs_xmit.c | 1 -
 1 file changed, 1 deletion(-)

Should work on any stable kernel, tested on
v3.10.81, v3.12.44, v3.14.45, v3.16.7, v3.18.16, v4.0.6

net/netfilter/ipvs/ip_vs_xmit.c +0 -1
index 19986ec..5fb7fd9 100644
@@ -130,7 +130,6 @@ static struct rtable *do_output_route4(struct net *net, __be32 daddr,
 
 	memset(&fl4, 0, sizeof(fl4));
 	fl4.daddr = daddr;
-	fl4.saddr = (rt_mode & IP_VS_RT_MODE_CONNECT) ? *saddr : 0;
 	fl4.flowi4_flags = (rt_mode & IP_VS_RT_MODE_KNOWN_NH) ?
 			   FLOWI_FLAG_KNOWN_NH : 0;
 
Signature · 1 line
1.9.3
maintainer
#1 lore raw
Quoted 11 lines · Julian Anastasov

Michael Vallaly reports about wrong source address used in rare cases for tunneled traffic. Looks like __ip_vs_get_out_rt in 3.10+ is providing uninitialized dest_dst->dst_saddr.ip because ip_vs_dest_dst_alloc uses kmalloc. While we retry after seeing EINVAL from routing for data that does not look like valid local address, it still succeeded when this memory was previously used from other dests and with different local addresses. As result, we can use valid local address that is not suitable for our real server.

Quoted 6 lines

Fix it by providing 0.0.0.0 every time our cache is refreshed. By this way we will get preferred source address from routing.

Fixes 026ace060dfe ("ipvs: optimize dst usage for real server")

Thanks, I have applied this to the ipvs tree.