]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
decnet: always not take dst->__refcnt when inserting dst into hash table
authorWei Wang <weiwan@google.com>
Fri, 16 Jun 2017 17:46:37 +0000 (10:46 -0700)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 19 Jul 2017 07:58:40 +0000 (09:58 +0200)
commitf8485e7324e80c3c9d9b4c910f49005d859821b9
treea9e4bbe15e219779fbbc0cc807e84315f83d2d26
parentca010aab75e1e6672355736f10f07808d7703520
decnet: always not take dst->__refcnt when inserting dst into hash table

BugLink: http://bugs.launchpad.net/bugs/1702863
[ Upstream commit 76371d2e3ad1f84426a30ebcd8c3b9b98f4c724f ]

In the existing dn_route.c code, dn_route_output_slow() takes
dst->__refcnt before calling dn_insert_route() while dn_route_input_slow()
does not take dst->__refcnt before calling dn_insert_route().
This makes the whole routing code very buggy.
In dn_dst_check_expire(), dnrt_free() is called when rt expires. This
makes the routes inserted by dn_route_output_slow() not able to be
freed as the refcnt is not released.
In dn_dst_gc(), dnrt_drop() is called to release rt which could
potentially cause the dst->__refcnt to be dropped to -1.
In dn_run_flush(), dst_free() is called to release all the dst. Again,
it makes the dst inserted by dn_route_output_slow() not able to be
released and also, it does not wait on the rcu and could potentially
cause crash in the path where other users still refer to this dst.

This patch makes sure both input and output path do not take
dst->__refcnt before calling dn_insert_route() and also makes sure
dnrt_free()/dst_free() is called when removing dst from the hash table.
The only difference between those 2 calls is that dnrt_free() waits on
the rcu while dst_free() does not.

Signed-off-by: Wei Wang <weiwan@google.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
net/decnet/dn_route.c