]> git.ipfire.org Git - thirdparty/iproute2.git/commit
ip-route: Fix segfault with many nexthops
authorPhil Sutter <phil@nwl.cc>
Thu, 6 Sep 2018 13:31:51 +0000 (15:31 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 10 Sep 2018 19:14:50 +0000 (12:14 -0700)
commitbd59e5b1517b09b6f26d59f38fe6077d953c2396
tree2da95580aafab2d63b26ef32adf93a17a60e743d
parent40c2916fda23bc9bd124009934544d3c0fddd1c0
ip-route: Fix segfault with many nexthops

It was possible to crash ip-route by adding an IPv6 route with 37
nexthop statements. A simple reproducer is:

| for i in `seq 37`; do
|  nhs="nexthop via 1111::$i "$nhs
| done
| ip -6 route add 3333::/64 $nhs

The related code was broken in multiple ways:

* parse_one_nh() assumed that rta points to 4kB of storage but caller
  provided just 1kB. Fixed by passing 'len' parameter with the correct
  value.

* Error checking of rta_addattr*() calls in parse_one_nh() and called
  functions was completely absent, so with above fix in place output
  flood would occur due to parser looping forever.

While being at it, increase message buffer sizes to 4k. This allows for
at most 144 nexthops.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/iproute.c
ip/iproute_lwtunnel.c