aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLance Richardson <lrichard@redhat.com>2016-03-22 14:56:57 -0400
committerDavid S. Miller <davem@davemloft.net>2016-03-22 15:59:23 -0400
commit4cfc86f3dae6ca38ed49cdd78f458a03d4d87992 (patch)
tree751d08a8a62e8ea5284b0b277675a5d451574897
parent6e9bdc7271ac8e2af58a2c9a87551d9bd49337a1 (diff)
ipv4: initialize flowi4_flags before calling fib_lookup()
Field fl4.flowi4_flags is not initialized in fib_compute_spec_dst() before calling fib_lookup(), which means fib_table_lookup() is using non-deterministic data at this line: if (!(flp->flowi4_flags & FLOWI_FLAG_SKIP_NH_OIF)) { Fix by initializing the entire fl4 structure, which will prevent similar issues as fields are added in the future by ensuring that all fields are initialized to zero unless explicitly initialized to another value. Fixes: 58189ca7b2741 ("net: Fix vti use case with oif in dst lookups") Suggested-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: Lance Richardson <lrichard@redhat.com> Acked-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/fib_frontend.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 21add552e56a..8a9246deccfe 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -280,7 +280,6 @@ __be32 fib_compute_spec_dst(struct sk_buff *skb)
280 struct in_device *in_dev; 280 struct in_device *in_dev;
281 struct fib_result res; 281 struct fib_result res;
282 struct rtable *rt; 282 struct rtable *rt;
283 struct flowi4 fl4;
284 struct net *net; 283 struct net *net;
285 int scope; 284 int scope;
286 285
@@ -296,14 +295,13 @@ __be32 fib_compute_spec_dst(struct sk_buff *skb)
296 295
297 scope = RT_SCOPE_UNIVERSE; 296 scope = RT_SCOPE_UNIVERSE;
298 if (!ipv4_is_zeronet(ip_hdr(skb)->saddr)) { 297 if (!ipv4_is_zeronet(ip_hdr(skb)->saddr)) {
299 fl4.flowi4_oif = 0; 298 struct flowi4 fl4 = {
300 fl4.flowi4_iif = LOOPBACK_IFINDEX; 299 .flowi4_iif = LOOPBACK_IFINDEX,
301 fl4.daddr = ip_hdr(skb)->saddr; 300 .daddr = ip_hdr(skb)->saddr,
302 fl4.saddr = 0; 301 .flowi4_tos = RT_TOS(ip_hdr(skb)->tos),
303 fl4.flowi4_tos = RT_TOS(ip_hdr(skb)->tos); 302 .flowi4_scope = scope,
304 fl4.flowi4_scope = scope; 303 .flowi4_mark = IN_DEV_SRC_VMARK(in_dev) ? skb->mark : 0,
305 fl4.flowi4_mark = IN_DEV_SRC_VMARK(in_dev) ? skb->mark : 0; 304 };
306 fl4.flowi4_tun_key.tun_id = 0;
307 if (!fib_lookup(net, &fl4, &res, 0)) 305 if (!fib_lookup(net, &fl4, &res, 0))
308 return FIB_RES_PREFSRC(net, res); 306 return FIB_RES_PREFSRC(net, res);
309 } else { 307 } else {