]> git.baikalelectronics.ru Git - kernel.git/commit
ipv6: Initialize rt6_info properly in ip6_blackhole_route()
authorMartin KaFai Lau <kafai@fb.com>
Thu, 15 Oct 2015 23:39:58 +0000 (16:39 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 16 Oct 2015 07:39:16 +0000 (00:39 -0700)
commita528223c98148c789541d75f8bf6c73ce7a522f0
tree34b1c01554617573d9da4389ff3c6955f677e6b4
parent50d4fe5c45cbc96898ff7b755c6fc5d907444a15
ipv6: Initialize rt6_info properly in ip6_blackhole_route()

ip6_blackhole_route() does not initialize the newly allocated
rt6_info properly.  This patch:
1. Call rt6_info_init() to initialize rt6i_siblings and rt6i_uncached

2. The current rt->dst._metrics init code is incorrect:
   - 'rt->dst._metrics = ort->dst._metris' is not always safe
   - Not sure what dst_copy_metrics() is trying to do here
     considering ip6_rt_blackhole_cow_metrics() always returns
     NULL

   Fix:
   - Always do dst_copy_metrics()
   - Replace ip6_rt_blackhole_cow_metrics() with
     dst_cow_metrics_generic()

3. Mask out the RTF_PCPU bit from the newly allocated blackhole route.
   This bug triggers an oops (reported by Phil Sutter) in rt6_get_cookie().
   It is because RTF_PCPU is set while rt->dst.from is NULL.

Fixes: 790d3035c2d0 ("ipv6: Create percpu rt6_info")
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Reported-by: Phil Sutter <phil@nwl.cc>
Tested-by: Phil Sutter <phil@nwl.cc>
Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
Cc: Julian Anastasov <ja@ssi.bg>
Cc: Phil Sutter <phil@nwl.cc>
Cc: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/route.c