Commit 450b9d8e authored by David Ahern's avatar David Ahern Committed by Greg Kroah-Hartman

neighbor: Reset gc_entries counter if new entry is released before insert

[ Upstream commit 64c6f4bb ]

Ian and Alan both reported seeing overflows after upgrades to 5.x kernels:
  neighbour: arp_cache: neighbor table overflow!

Alan's mpls script helped get to the bottom of this bug. When a new entry
is created the gc_entries counter is bumped in neigh_alloc to check if a
new one is allowed to be created. ___neigh_create then searches for an
existing entry before inserting the just allocated one. If an entry
already exists, the new one is dropped in favor of the existing one. In
this case the cleanup path needs to drop the gc_entries counter. There
is no memory leak, only a counter leak.

Fixes: 58956317 ("neighbor: Improve garbage collection")
Reported-by: default avatarIan Kumlien <ian.kumlien@gmail.com>
Reported-by: default avatarAlan Maguire <alan.maguire@oracle.com>
Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
Tested-by: default avatarAlan Maguire <alan.maguire@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 713f03fa
......@@ -663,6 +663,8 @@ static struct neighbour *___neigh_create(struct neigh_table *tbl,
out_tbl_unlock:
write_unlock_bh(&tbl->lock);
out_neigh_release:
if (!exempt_from_gc)
atomic_dec(&tbl->gc_entries);
neigh_release(n);
goto out;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment