]> git.baikalelectronics.ru Git - kernel.git/commit
ipv4: Avoid crashing in ip_error
authorEric W. Biederman <ebiederm@xmission.com>
Fri, 22 May 2015 09:58:12 +0000 (04:58 -0500)
committerDavid S. Miller <davem@davemloft.net>
Fri, 22 May 2015 18:23:40 +0000 (14:23 -0400)
commitf99d8134c06160f6bd30d4f75c9ce84231eeae8c
treebf61132f699afbdc3d906fac7185d2320474a59c
parentef198329252e75d1fb01e25f5b3695fdd03fe2bc
ipv4: Avoid crashing in ip_error

ip_error does not check if in_dev is NULL before dereferencing it.

IThe following sequence of calls is possible:
CPU A                          CPU B
ip_rcv_finish
    ip_route_input_noref()
        ip_route_input_slow()
                               inetdev_destroy()
    dst_input()

With the result that a network device can be destroyed while processing
an input packet.

A crash was triggered with only unicast packets in flight, and
forwarding enabled on the only network device.   The error condition
was created by the removal of the network device.

As such it is likely the that error code was -EHOSTUNREACH, and the
action taken by ip_error (if in_dev had been accessible) would have
been to not increment any counters and to have tried and likely failed
to send an icmp error as the network device is going away.

Therefore handle this weird case by just dropping the packet if
!in_dev.  It will result in dropping the packet sooner, and will not
result in an actual change of behavior.

Fixes: e96dd551a68af ("ipv4: Cache ip_error() routes even when not forwarding.")
Reported-by: Vittorio Gambaletta <linuxbugs@vittgam.net>
Tested-by: Vittorio Gambaletta <linuxbugs@vittgam.net>
Signed-off-by: Vittorio Gambaletta <linuxbugs@vittgam.net>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/route.c