]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/5.1.9/neighbor-reset-gc_entries-counter-if-new-entry-is-released-before-insert.patch
Linux 5.1.9
[thirdparty/kernel/stable-queue.git] / releases / 5.1.9 / neighbor-reset-gc_entries-counter-if-new-entry-is-released-before-insert.patch
1 From foo@baz Sun 09 Jun 2019 09:24:16 AM CEST
2 From: David Ahern <dsahern@gmail.com>
3 Date: Wed, 1 May 2019 18:08:34 -0700
4 Subject: neighbor: Reset gc_entries counter if new entry is released before insert
5
6 From: David Ahern <dsahern@gmail.com>
7
8 [ Upstream commit 64c6f4bbca748c3b2101469a76d88b7cd1c00476 ]
9
10 Ian and Alan both reported seeing overflows after upgrades to 5.x kernels:
11 neighbour: arp_cache: neighbor table overflow!
12
13 Alan's mpls script helped get to the bottom of this bug. When a new entry
14 is created the gc_entries counter is bumped in neigh_alloc to check if a
15 new one is allowed to be created. ___neigh_create then searches for an
16 existing entry before inserting the just allocated one. If an entry
17 already exists, the new one is dropped in favor of the existing one. In
18 this case the cleanup path needs to drop the gc_entries counter. There
19 is no memory leak, only a counter leak.
20
21 Fixes: 58956317c8d ("neighbor: Improve garbage collection")
22 Reported-by: Ian Kumlien <ian.kumlien@gmail.com>
23 Reported-by: Alan Maguire <alan.maguire@oracle.com>
24 Signed-off-by: David Ahern <dsahern@gmail.com>
25 Tested-by: Alan Maguire <alan.maguire@oracle.com>
26 Signed-off-by: David S. Miller <davem@davemloft.net>
27 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28 ---
29 net/core/neighbour.c | 2 ++
30 1 file changed, 2 insertions(+)
31
32 --- a/net/core/neighbour.c
33 +++ b/net/core/neighbour.c
34 @@ -663,6 +663,8 @@ out:
35 out_tbl_unlock:
36 write_unlock_bh(&tbl->lock);
37 out_neigh_release:
38 + if (!exempt_from_gc)
39 + atomic_dec(&tbl->gc_entries);
40 neigh_release(n);
41 goto out;
42 }