Daniel Borkmann 0409c9a5a7 net: fib6: fib6_commit_metrics: fix potential NULL pointer dereference
When IPv6 host routes with metrics attached are being added, we fetch
the metrics store from the dst via COW through dst_metrics_write_ptr(),
added through commit e5fd387ad5b3.

One remaining problem here is that we actually call into inet_getpeer()
and may end up allocating/creating a new peer from the kmemcache, which
may fail.

Example trace from perf probe (inet_getpeer:41) where create is 1:

ip 6877 [002] 4221.391591: probe:inet_getpeer: (ffffffff8165e293)
  85e294 inet_getpeer.part.7 (<- kmem_cache_alloc())
  85e578 inet_getpeer
  8eb333 ipv6_cow_metrics
  8f10ff fib6_commit_metrics

Therefore, a check for NULL on the return of dst_metrics_write_ptr()
is necessary here.

Joint work with Florian Westphal.

Fixes: e5fd387ad5b3 ("ipv6: do not overwrite inetpeer metrics prematurely")
Cc: Michal Kubeček <mkubecek@suse.cz>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-01-05 22:55:24 -05:00
..
2014-11-24 04:28:48 -05:00
2014-12-09 16:29:03 -05:00
2014-11-24 04:28:48 -05:00
2014-12-09 16:29:03 -05:00
2014-12-07 21:22:05 +01:00
2014-11-24 04:28:51 -05:00
2014-12-14 16:10:09 -08:00
2014-11-24 04:28:48 -05:00
2014-11-24 04:28:48 -05:00
2014-11-24 04:28:48 -05:00
2014-12-14 16:10:09 -08:00
2014-11-24 04:28:48 -05:00
2014-12-10 15:13:13 -08:00
2014-12-31 13:11:39 -05:00
2014-12-09 16:29:03 -05:00
2014-12-09 16:29:03 -05:00
2014-11-24 04:28:48 -05:00
2014-12-09 16:29:03 -05:00
2014-12-19 07:13:21 -05:00