🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #12445

Re: [PATCH] neighbour: Move the netdev_put() out of RCU callback

#12445
From: "Zqiang"
Date: Sat, 07 Nov 2026 11:47
102 lines
11050 bytes
> 
> On Fri, Oct 9, 2026 at 2:19 AM Zqiang <qiang.zhang@linux.dev> wrote:
> 
> > 
> > For builts with CONFIG_NET_DEV_REFCNT_TRACKER=y kernels, netdev_put()
> >  records the caller's stack trace via ref_tracker_free() for debugging
> >  reference leaks. however, the netdev_put() is within pneigh_destroy()
> >  RCU callback, this recorded stack is uninformative, it does not reveal
> >  which code path initiated the deletion.
> > 
> Have you seen pneigh double-free ? What motivates this change ?

Firstly, Apologies for delayed reply.



Actually, I didn't see any double-free happening,  just wanted it to
record a meaningful callstack which on release path.  After all, if double-free
really occurs, the callstack of the RCU callback execution path will not be helpful.


> 
> > 
> > This commit therefore move netdev_put() from the RCU callback into the
> >  caller's process context, and replace call_rcu() with kfree_rcu().
> > 
> >  Fixes: d539d8fbd8fc ("neighbour: Free pneigh_entry after RCU grace period.")
> > 
> Please elaborate why your change is safe in the commit message
> and remove the tag.

Does it refer to using kfree_rcu instead of call_rcu ensures safely ?

Thanks
Zqiang

> 
> > 
> > Signed-off-by: Zqiang <qiang.zhang@linux.dev>
> > 
> nit: full name
> 
> > 
> > ---
> >  net/core/neighbour.c | 14 ++++----------
> >  1 file changed, 4 insertions(+), 10 deletions(-)
> > 
> >  diff --git a/net/core/neighbour.c b/net/core/neighbour.c
> >  index 6ed8eb075146..4263689fc415 100644
> >  --- a/net/core/neighbour.c
> >  +++ b/net/core/neighbour.c
> >  @@ -818,14 +818,6 @@ int pneigh_create(struct neigh_table *tbl,
> >  return err;
> >  }
> > 
> >  -static void pneigh_destroy(struct rcu_head *rcu)
> >  -{
> >  - struct pneigh_entry *n = container_of(rcu, struct pneigh_entry, rcu);
> >  -
> >  - netdev_put(n->dev, &n->dev_tracker);
> >  - kfree(n);
> >  -}
> >  -
> >  int pneigh_delete(struct neigh_table *tbl, const void *pkey,
> >  struct net_device *dev)
> >  {
> >  @@ -849,7 +841,8 @@ int pneigh_delete(struct neigh_table *tbl, const void *pkey,
> >  if (tbl->pdestructor)
> >  tbl->pdestructor(n);
> > 
> >  - call_rcu(&n->rcu, pneigh_destroy);
> >  + netdev_put(n->dev, &n->dev_tracker);
> >  + kfree_rcu(n, rcu);
> >  return 0;
> >  }
> >  }
> >  @@ -891,7 +884,8 @@ static void pneigh_ifdown(struct neigh_table *tbl, struct net_device *dev,
> >  if (tbl->pdestructor)
> >  tbl->pdestructor(n);
> > 
> >  - call_rcu(&n->rcu, pneigh_destroy);
> >  + netdev_put(n->dev, &n->dev_tracker);
> >  + kfree_rcu(n, rcu);
> >  }
> >  }
> > 
> >  --
> >  2.17.1
> >
>
Technical Details
Message-ID: <a951af6957fe4890d3eaaf5a661754fc259a4b79@linux.dev>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358344-linux-kernel-netdev=dewy.ru
References: <20261009091941.5837-1-qiang.zhang@linux.dev> <CAAVpQUAeHP7M07uMweRePtuzPPUo-99dL6jOYUiVf7CSVUxNDQ@mail.gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358344-linux-kernel-netdev=dewy.ru
From: qiang.zhang@linux.dev ("Zqiang")
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH] neighbour: Move the netdev_put() out of RCU callback
Date: Sat, 07 Nov 2026 11:47:45 +0000
Organization: Usenet Network
Message-ID: <a951af6957fe4890d3eaaf5a661754fc259a4b79@linux.dev>
References: <20261009091941.5837-1-qiang.zhang@linux.dev>
 <CAAVpQUAeHP7M07uMweRePtuzPPUo-99dL6jOYUiVf7CSVUxNDQ@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="4095055"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:I0+KxAHV2ztqilhDjQKEUUoOqUQ= sha256:OGeL7V5tWZLCIJHYOAs7m1XClPV2ppcxsDFjFvT/Joc=
	sha1:XTdUClar6GTSIIULLVW8BcnCIcs= sha256:8r4/5YuHKaLOVC/fPPnZ7r3ZE3R0aCOvXndmXtEgIuU=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 4EF07113407; Sat,  7 Nov 2026 15:01:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.15
X-Spam-Status: No, score=-3.15 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.dev
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id RU1JroMuv3hb;
	Sat,  7 Nov 2026 15:01:00 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-358344-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id DAA29113403; Sat,  7 Nov 2026 15:00:51 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 7E2623FC3A; Sat,  7 Nov 2026 11:47:58 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794052075;
	b=SrdSj5TBljrQI8xnXYccHLw7XEZchFDZQtjwLsr3r1MvN0TEqeP452DXcAZFzuQVbOch
	 0ZbTtC+j2E+Xnz65iWQIHkllVDTGuPPGwwoDycYhHxTKBAzINNKMsJ204j7io1byvRyTC
	 2Tv5JAQSs/hSw8MIXYwPU0v9/sFpHr59zHiV1sUo3xbw0ez9g4kRZPmdq9sdZkTzoasfU
	 Bn1953utiF+/r09LXlJbIjNuuZFy6SayzPx2r68d7MqfXA+OrLUFGJ05qQjfheerB2il1
	 dXbZyNCOdUH4LtiE6mns3Jd3OY4YIGOGWBO4oJ22a5/vXUo9MowNaee804pZa1dnf/g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794052075;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Date:Content-Type:
	 Content-Transfer-Encoding:From:Message-ID:TLS-Required:Subject:To:Cc:
	 In-Reply-To:References;
	bh=GnHezEpsy7TwQxHl7QCtA4TWsPZS/fezs0Pa1IH2a4Q=;
	b=TbSI+Sr6Kgxv77wOuU3kRSQL1q8eKdO2kPXu1iYTdzXoOTU5Z8J1hGqhfzd0FzhRYaDf
	 a1EnuVcvuyyAHzBnsD8TzhGJuGIZythhaGfBwUdIOtHoii/OTliXQaTdqgaSdxnAJmoiJ
	 ysXg3OcsfaWT2pwpb33Xj5cwsFMFl5BDyOIPzbEaeWJPCl1bYWZQPAGUpyinCtLuA9icv
	 1dd2yky1VaRuJjM1vjyagwii3RQZxEPUIVCke3sHgxjHnHt5gq5tLWWF4vPZZgJ5Zh0nj
	 KnFdWfkFw+eVeajuXDGEyKWuUZJ4O6t/Ybj33ii0mZ+uE5FklT0A/SwZHHNSSIU2kqw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=p35pArLu;
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 33AEA606A339;
	Sat,  7 Nov 2026 11:47:55 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=p35pArLu
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.26
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794052069;
	b=fpOOT7lMSLaLMUsWelsXQ+zvW/3zdnmgwp37PjXaOmrF0eQq1q9VP82UAPoLPZ0rec8k
	 oqO1aukAzYgjQZgRDzMiNPY8s4iLq2iValNfbIJSfigzhj4bRszHmeO824mfnDYCK4Vak
	 vcgw6Nj5pkYJEZ+1jxTfpnD2bAkLGcY8lpdd4OsIkSnsJyY8+u9Ry3Gfiqr2rmNLwn+d5
	 Omcm/ILQSR8W1uAgogfeqK+8sG+qkJJDLu0jOU/4uJvndiMb00ApyZW0KBCI2yf0XxRMJ
	 TUGBnX46U5NUhozUoKPID3HfTN0NhwZsKMpu7OO5gYyteEpCtByNdziXvklOAq/Oq+Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794052069;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:MIME-Version:Date:Content-Type:
	 Content-Transfer-Encoding:From:Message-ID:TLS-Required:Subject:To:Cc:
	 In-Reply-To:References;
	bh=GnHezEpsy7TwQxHl7QCtA4TWsPZS/fezs0Pa1IH2a4Q=;
	b=P5hAPFCvX4IEusaYN+WkAoLv8nHbeJOKfXQtn/i0YdCjeMMOW1weUqJqL5dUYrlPurB7
	 Dv2Q738bwuz6ZGJIOXVZ0RLRXrfN2NGhEqd1/W0/crdMk5mFSjewgu+kbr7rhGEVlUx6R
	 vmexzvNH2Qs2qLyYyFCFmzKyCcLWLHx6U8M3tfl4oyhyg0CyTWI5b6wypo5Mrz54sn5ap
	 uuWUPiQ8UDe6Ib9WsONewz5U/POCm3WgLcN13WfMGTwrbjPolOtoWYKsYIz7sQoeRIVqZ
	 WLCwlQRooXL9F1b25EFXNAxN8OX0wvQA8RVZ1kL0IIWPUFh1igITW/xDPw+lAbZ8nJg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=p35pArLu;
	arc=none smtp.remote-ip=91.218.175.26
X-Received: from mta0.migadu.com (out-26.mta0.migadu.com [91.218.175.26])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 341C0606A332
	for <netdev@vger.kernel.org>; Sat,  7 Nov 2026 11:47:47 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 341C0606A332
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=Xagw4uV/cJ7unFmTqNMB0IDgo84IicTToPr/WXewfaI=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1794052066; v=1; x=1794656866;
 b=p35pArLuJ3P4B8gSCE7O0EMkeuGZkNORiT5GAkNt0vagOrGUXSVmb7QrboQIh4ZJtqs2Ggx/
 /58ab1+yO73qJtqSeqO/wUR01zAl71tx964nL3IIBPRJZ3/f6J3fUfRbLXKUo13gz8XDNUMU+sH
 pJ9l5E6Wu71julLJeNPhs+WU=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by smtp.migadu.com with ESMTPS id 86d04180e8eba885;
	Sat, 07 Nov 2026 11:47:45 +0000
X-Mizu-Trace-ID: 86d04180e8eba885
X-Migadu-Flow: FLOW_OUT
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-TLS-Required: No
X-Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
 pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <CAAVpQUAeHP7M07uMweRePtuzPPUo-99dL6jOYUiVf7CSVUxNDQ@mail.gmail.com>