Article View: linux.kernel.netdev
Article #24806[PATCH net 04/10] netfilter: conntrack: wait for RCU readers before freeing the hash
From: Pablo Neira Ayuso
Date: Mon, 30 Nov 2026 21:51
Date: Mon, 30 Nov 2026 21:51
62 lines
10412 bytes
10412 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:
<20261130215141.1009148-5-pablo@netfilter.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374480-linux-kernel-netdev=dewy.ruReferences:
<20261130215141.1009148-1-pablo@netfilter.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374480-linux-kernel-netdev=dewy.ru From: pablo@netfilter.org (Pablo Neira Ayuso) Newsgroups: linux.kernel.netdev Subject: [PATCH net 04/10] netfilter: conntrack: wait for RCU readers before freeing the hash Date: Mon, 30 Nov 2026 22:51:35 +0100 Organization: Usenet Network Message-ID: <20261130215141.1009148-5-pablo@netfilter.org> References: <20261130215141.1009148-1-pablo@netfilter.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1547557"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:jBknuJDdyrqefpuNKKByitgnBWc= sha256:i2A1xf0RovNrH2F9YuBqCDqT6AkTavT9N0dt5VqrBcY= sha1:96rdWmbKQN3u8iHSVSX0f9hkNeI= sha256:4m1yq1b0obAVPlUiqNakVNEbnaHjiaJkbBXXiSGk+B8= 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 E0504126007; Tue, 1 Dec 2026 00:52:20 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.151 X-Spam-Status: No, score=-3.151 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] 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 ZrodD8Pr0s_f; Tue, 1 Dec 2026 00:52:18 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-374480-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 1805E126015; Tue, 1 Dec 2026 00:52:09 +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 F04C02948C; Mon, 30 Nov 2026 21:52:00 +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=1796075515; b=UQ/XTNHOLUTKEBX95qJSiwiFhBeSkW967HIANLdaenwaGNSp0nkAduDXMTjymqzvO1ci uN2PhdFhkcHLD/njxGy1Ky+KuhbrDjTMTKHB2ptm576giuEbeUjbtLY4MzcnziCYlSJv6 uV2PWjNdnJwLL8Dn4Z8pDnr0/M3bMtmf6vwKJYoHgoobzeDGrt/X97UG9C196AhDFmS2G f3/fTDKmc1xb10rS/hCEySV5Cm0QJr8CACvE42gd1uewku45dqgp9Ik5sc3N2oG0dH6fV onOKkZVefzWgtmOqCfNOdWWVmAsh8cSBVsIKX/oniUp4Bvd7/7pwiEjb/hc0pHwhQQw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796075515; 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=PPwLagNjLiiSneJF2zOqirVpQXuIlx0l2JrMFDF54hysNhUpOhHv4kd76nttH2SIVJ7W VnOh4cU/9PhMaZTOTh5MBf5p/p6ahgWUVFeFA68zsPgh/Kuv+IkLcI4fRoiJo1yjhmPDx NioCzooLFjHLHH96Iy1JBFbmd7VrYMo+X2hdCaoNIqk38N/DZHkDpkQviJLZ7Q4Kbw4jt JxSbeV/2XyOnmiXVu3ObIEqHNCbdCIyk81vV2bvnpSXuuZL8VylJ4sdNzLVhquMp0sk/t M7NBFv9wQVaGlfDEUY4HpEUExsQxMFGjpvtFUhbYm2UkiLJ2D65fVuNGxLapTcTOvPw== 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=lvJ3QXFB; 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 17DD4606A33C; Mon, 30 Nov 2026 21:51:55 +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=lvJ3QXFB 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=1796075514; b=Je1cYwK9c0dzkyYYSWJwFPGBM7RM0O8Ix/PFDvHgk9TttOE0TijEy6TXwOXDw/OWipyD RqKENoNAjzLI8QDlZx3DCiq9IrqKuYlmhSMx8Gvd+wwOE7W9ohqmUFXFFu3SlJFIIY1vf fnqsthb2XOgsmnvYjfXwmYsNKjpMzcORIYfWORCZcj7eO+chkL/3Am5Wfh1TQF8vZI+GN 9+I/mynijDk9/6Ik1NiD+aYjGJeNQFVshBRAjo9Djpf3A1zSmwnKS0F3k+N+FuRrA8IqA ES6obEW93wXb2TP6Bx50wHz8fYp1FSzjbSjy2eNGJpfSeal9rhpK/FtfUoDMbNLyC0Q== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796075514; 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=ug8/oMRf4g8X5fdB3RH89FiMr/lUuws9isJaJ5DnLWgmGKEBsjQjY/xJjUX7HgLFSDGe Eytf+iNIX75MyU6fRZdkea2htZ0GdzFkK0CiUttbOT4h1XCVwKcey6Hl9oa+n+di/HN8t Hslg9hHqUtqERC9AFSHz7IYpSA32VlfFlT859OLbNWlcmsnvlC/xpl4/A20AlN6WX+qyU it6AzutPzMXyKsWNnFw2XzeDx9a7M2OHdKFB1F7goq+lMRuWQUGNYubRB0C025h6UEpY0 MuIO8UA+kdIwO8Vdp2zIaaemVWWuKOc9Rk9b5aU3l5DEsVqHVZJqwPgfPAeFA/oLDag== 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=lvJ3QXFB; 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 C23DB606A680; Mon, 30 Nov 2026 21:51:53 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C23DB606A680 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=1796075512; bh=xZ3eqTZp6NQwb56oG2R4X/2aLhW4tkf227FdSJvTBLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lvJ3QXFBuZvwKup0k8Bh4LZvXP5bgSmeCJcwzRlHUohhxN8DJvxzT6+F+ZGkgyxN8 TrtIbHNEmwSIZINV3cRtymhomP0gPjO3lKSF6E4aTveRw0sMf7Fd+zXsKCVvRO74x3 rkxQwtkYwRuPkj7hFy10l1HgNaWAYGIlFnA3YvXQ5oTekzrNHwO/tm0voFAUYLOcti /cuU3CqMlmfLvRHr1K1FFE8bcbWTqTSC8cUGYaNTuZVcunqaxf+D5Ey2MwNGwGX583 tGADficH1JGJPlMmI5DisMCDL22PbUSPU6Kc1u5D/dHxn3sB6PKg5/6GaT23vWHO2d mvTYTdpRLur9w== X-Received: from localhost.localdomain (mail-agni [217.70.190.124]) by mail.netfilter.org (Postfix) with ESMTPSA id 77FFA6007D; Mon, 30 Nov 2026 22:51:51 +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: <20261130215141.1009148-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