From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45D62C43219 for ; Thu, 2 May 2019 01:09:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0B1F22085A for ; Thu, 2 May 2019 01:09:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556759354; bh=eDnCcVuw6O877czZYd2o/YChmQa+wdNOS6NNA4tuGcU=; h=From:To:Cc:Subject:Date:List-ID:From; b=YZAY6rKICHWh9pIFyO0MMRF7MV09IPu/2bJ9tFQxGeHKrLY41it0nTN9zs3hWkCrT XMpRJxqlXLTBS3vc5b6J+sIItLPMu9va/KvByNyHLRcvdSotuzMoEXv4rpq5Q9nf8D YWCeZaPKJ1VTYsNkpTtDfK1PV6DNlXyUAf/FA7F0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726183AbfEBBH1 (ORCPT ); Wed, 1 May 2019 21:07:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:37406 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726133AbfEBBH1 (ORCPT ); Wed, 1 May 2019 21:07:27 -0400 Received: from kenny.it.cumulusnetworks.com. (fw.cumulusnetworks.com [216.129.126.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C04572085A; Thu, 2 May 2019 01:07:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556759246; bh=eDnCcVuw6O877czZYd2o/YChmQa+wdNOS6NNA4tuGcU=; h=From:To:Cc:Subject:Date:From; b=GKnID9KpWdKTA++knJKaS+lFJS9MYwmb9lrofAdAaX8vCeYPmcGpgVzQ7g869fpP/ 3pog1fg9p7J+c4rafoS4ao1UC8W+xgLZ/PHdCjN6FTkGp/Hr82IcOgnSZk5dkS6ahl /pe3Ey8fuBD201fnBn2pq2IPlpsJGXDuxy2pCJKU= From: David Ahern To: davem@davemloft.net Cc: netdev@vger.kernel.org, ian.kumlien@gmail.com, alan.maguire@oracle.com, David Ahern Subject: [PATCH net] neighbor: Reset gc_entries counter if new entry is released before insert Date: Wed, 1 May 2019 18:08:34 -0700 Message-Id: <20190502010834.25519-1-dsahern@kernel.org> X-Mailer: git-send-email 2.11.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Ahern 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: 58956317c8d ("neighbor: Improve garbage collection") Reported-by: Ian Kumlien Reported-by: Alan Maguire Signed-off-by: David Ahern --- net/core/neighbour.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 30f6fd8f68e0..aff051e5521d 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -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; } -- 2.11.0