]> git.baikalelectronics.ru Git - kernel.git/commit
netdevsim: fib: Fix reference count leak on route deletion failure
authorIdo Schimmel <idosch@nvidia.com>
Thu, 28 Jul 2022 11:45:33 +0000 (14:45 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 29 Jul 2022 11:21:02 +0000 (12:21 +0100)
commit16dfd75c97bc070650f293a71eee38500b7b1a2e
treebeff375385e41df942eec1071536b75d95af50bf
parent08d51509b9f73c2685a2d4e53fd7d8a4d2151827
netdevsim: fib: Fix reference count leak on route deletion failure

As part of FIB offload simulation, netdevsim stores IPv4 and IPv6 routes
and holds a reference on FIB info structures that in turn hold a
reference on the associated nexthop device(s).

In the unlikely case where we are unable to allocate memory to process a
route deletion request, netdevsim will not release the reference from
the associated FIB info structure, thereby preventing the associated
nexthop device(s) from ever being removed [1].

Fix this by scheduling a work item that will flush netdevsim's FIB table
upon route deletion failure. This will cause netdevsim to release its
reference from all the FIB info structures in its table.

Reported by Lucas Leong of Trend Micro Zero Day Initiative.

Fixes: 56f51c8d9d8b ("netdevsim: fib: Perform the route programming in a non-atomic context")
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/netdevsim/fib.c