Article View: linux.kernel.netdev
Article #24006[PATCH net 04/14] netfilter: conntrack: wait for RCU readers before freeing the hash
From: Pablo Neira Ayuso
Date: Sun, 29 Nov 2026 00:07
Date: Sun, 29 Nov 2026 00:07
62 lines
10468 bytes
10468 bytes
From: Chengfeng Ye <nicoyip.dev@gmail.com>
nf_ct_get_tuple_skb() calls into conntrack under rcu_read_lock() without
holding a module reference. CAKE can use this hook to look up a packet
without an attached conntrack, even during nf_conntrack module teardown.
nf_conntrack_cleanup_end() clears nf_ct_hook but frees nf_conntrack_hash
without waiting for existing readers. The grace period in per-net cleanup
runs while the hook is still published, so a later reader can race as
follows:
CPU 0 (packet path) CPU 1 (module teardown)
rcu_read_lock()
ct_hook = rcu_dereference(nf_ct_hook)
RCU_INIT_POINTER(nf_ct_hook, NULL)
kvfree(nf_conntrack_hash)
ct_hook->get_tuple_skb()
nf_conntrack_find_get()
access freed hash bucket
rcu_read_unlock()
The same missing grace period affects initialization failure after
nf_conntrack_init_end() publishes the hook. During module teardown,
KASAN reported:
BUG: KASAN: vmalloc-out-of-bounds in __nf_conntrack_find_get.isra.0
Read of size 8 at addr ffffc900012e2ae0 by task poc/90
Call Trace:
__nf_conntrack_find_get.isra.0+0xf87/0x10c0 [nf_conntrack]
nf_conntrack_get_tuple_skb+0x255/0x400 [nf_conntrack]
nf_ct_get_tuple_skb+0x75/0xb0
cake_hash+0xfdb/0x1e10
cake_enqueue+0x5cd/0x36e0
dev_qdisc_enqueue+0x40/0x170
__dev_queue_xmit+0x1e90/0x3110
Wait for an RCU grace period after clearing nf_ct_hook, before releasing
the hash table and the remaining conntrack resources.
Fixes: b60a60405fb9 ("netfilter: Add nf_ct_get_tuple_skb global lookup function")
Cc: stable@vger.kernel.org
Signed-off-by: Chengfeng Ye <nicoyip.dev@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 931b76aacd93..0cb5320883bd 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -2454,6 +2454,7 @@ void nf_conntrack_cleanup_start(void)
void nf_conntrack_cleanup_end(void)
{
RCU_INIT_POINTER(nf_ct_hook, NULL);
+ synchronize_rcu();
cancel_delayed_work_sync(&conntrack_gc_work.dwork);
kvfree(nf_conntrack_hash);
--
2.47.3
Technical Details
Message-ID:
<20261129000724.797425-5-pablo@netfilter.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373301-linux-kernel-netdev=dewy.ruReferences:
<20261129000724.797425-1-pablo@netfilter.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373301-linux-kernel-netdev=dewy.ru From: pablo@netfilter.org (Pablo Neira Ayuso) Newsgroups: linux.kernel.netdev Subject: [PATCH net 04/14] netfilter: conntrack: wait for RCU readers before freeing the hash Date: Sun, 29 Nov 2026 01:07:14 +0100 Organization: Usenet Network Message-ID: <20261129000724.797425-5-pablo@netfilter.org> References: <20261129000724.797425-1-pablo@netfilter.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1064109"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:u1pCIEbaaGXxVyAhwUPfu+r72fY= sha256:LAIig6/LWSoQKfv1X5B1MnvnlqDBvpgtCCLaRoYR9Bc= sha1:z0tqPfkqxdbJtwNn6FzXgnV0ZQM= sha256:gul9rC41b8Yq6XLXWOWfE4q//RS0YQMn3AeOu0VUzKg= 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 759D8125F91; Sun, 29 Nov 2026 03:08:00 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, 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 (2048-bit key) header.d=netfilter.org 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 5TGmoLSZ2AWY; Sun, 29 Nov 2026 03:07:58 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-373301-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=netfilter.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id B6DE0125F88; Sun, 29 Nov 2026 03:07:49 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id E06BD25241; Sun, 29 Nov 2026 00:07:41 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1795910858; b=MnoAAnVqT5tDyvkxdoVumEVh0hHocM4bavdDkPEUtvx5zlbShFZXvvjAD561KjWe4vaD w/gsu1APijsJSl/AZA8ZbeeMCc+Z+gE6ZMi5MEgv2gXvllGHjMNQjVMacs9s0PAeFNw1h bIQwufr0+OQs1dEIQ/milfNUBvBZyVPFB8K08MxVe/EQW4cErdXdzSDPKnzAtZqZ3cPDD kDxH7vZPM5/EzQ/FIZQrPgmuPUJaCFcV7td9/ssm6glQVV+EwsNQCYOHcKTKRBSSFUojl Gfn3Mq9eXrKIbbq7EI0JjxHVGMZ0dVyzwC23b/hpgRSnksLF61k+HStNOrzb/+01CRw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795910858; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=xZ3eqTZp6NQwb56oG2R4X/2aLhW4tkf227FdSJvTBLY=; b=S0vZxkkAnx92dHaFjU4yfxSzleRZ6YkZwfxc8dMGrnTqORyCFujRE93bjON4nUFnVjk/ ygxqL8sQxZMNgKkGESsxLm77cBcgPRmbTpu8iQDdyrOpDQxDEUjc3t7vnxlWkY/On+uYe xk4pTHZKHCixGW3SG3l4I2zYALtB1YLBlXPwGGGztbNaYRndhhRvojUSaSmi2BHadw+mV K3tHKrJZmQEXT/NbbQZxcA+6x0YDiII0VPNOk4WBWrj2V7+7x/u8xb39VBYdp1Yely+vE qSlzpWWa3Qm+YpB1PBOFaqDd059UGH65jMwOT99HXeFeeM7mLz3p6bua1aOru3Du43Q== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=cAFoaaUX; dmarc=none header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; arc=fail 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 526A2606A31C; Sun, 29 Nov 2026 00:07:38 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=cAFoaaUX X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.70.190.124 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795910857; b=NpV9Y2VtfrM4TQqkM79NMXZzr5GXdAdXcR1zp07xohmXTQCOGVhdvU/EFDPT3E5zUwC9 B2IDLg4wyci+ABDh83YbsnmxgJjstBpB8FBLKyuCOoqPVaElC1oZNgjvKMYB9cMdz7UJ5 iJ3EWuaCNnTrnkn+XYP3TAciyHUJ+hBHPtmvjCSgerVjsvMkythB9DjB/U8YE5JS1z0se ysYCn+uRFd6FClZp+p6Bxrl7CrpfJlK4IfyZQIzVS/GIhGqN8LjDcEzNJZymKnaJRsVel Ur3/LfuWskcBkEsqNReCiiKuXrA4nFaDFfFki5UIMPq3oyyWFsfNreLLOdMEsosU3Ow== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795910857; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Spam-Status:X-Spam-Checker-Version; bh=xZ3eqTZp6NQwb56oG2R4X/2aLhW4tkf227FdSJvTBLY=; b=4xl+ZJpadx0yMTBW1HFCHIjC8vI8Imt6P3T/mQOig+Bn0BEhdpeonGx0SKKrpiNwIJZc z2r70CvQhowVqhKLODj8GhFMKmdFSemR1HJpgmoWCbWrgAN9Lh7lbyd0FTVgz5lbIZvyU Np3DPMXQCXYaSQI54S9rYvBeY95wmYHIBrPteQEFSAKJJYagooZVr7i3WXiewfeu8TtPg QhNTdURVaxHFNkJ/uXVgeMgMDx199fIE/X/deUhixCqSjvJBpnp4SIvnnS/bFR7ZpydNQ T7m3EnzM5Xv/FM699RlHcUt22n/RGXDNZW5R7KT4eTgw3Oqk5424Z3PMsxycMpTAqgA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=cAFoaaUX; arc=none smtp.remote-ip=217.70.190.124 X-Received: from mail.netfilter.org (mail.netfilter.org [217.70.190.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06A8D606A336; Sun, 29 Nov 2026 00:07:36 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 06A8D606A336 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org; s=2025; t=1795910855; bh=xZ3eqTZp6NQwb56oG2R4X/2aLhW4tkf227FdSJvTBLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cAFoaaUXQCsIbsoHw0V+RLWtkOswXDBrA3GpXMpDVYKXCAfB8bJM6Yr4GVokFbmmE gPI7D0c/LwCxjdD8yCDuuCH0KWFjGQaC6/Y54YtMTDg6WTbkX4Dv6u29M1NZoeO+IJ 1rUOXQdHoIL7QlyJEBQ8IVOsHC4OCxdCv0EYa3QCDO8uQRaqDOsd85QMfFYFTjjAVo rJ0htS/EPHPy2Bt27F32mgwvkcCyLv1YavtrQUDuu878PORUYnkrH4QpS7oEivRn/f aJZlmSsjIIsrf56etekHbGCQkTWSPAHYnr1kcMN/HPE+cfsRxCenV3Mbkqtr5qC/lq EPgjhWBrJbDMw== X-Received: from localhost.localdomain (mail-agni [217.70.190.124]) by mail.netfilter.org (Postfix) with ESMTPSA id BF35E601B7; Sun, 29 Nov 2026 01:07:34 +0100 (CET) X-Cc: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org, horms@kernel.org, fw@strlen.de, ja@ssi.bg X-Mailer: git-send-email 2.47.3 X-In-Reply-To: <20261129000724.797425-1-pablo@netfilter.org> 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