Article View: linux.kernel.netdev
Article #24807[PATCH net 07/10] netfilter: conntrack: skip unconfirmed entries in /proc/net/nf_conntrack
From: Pablo Neira Ayuso
Date: Mon, 30 Nov 2026 21:51
Date: Mon, 30 Nov 2026 21:51
59 lines
10807 bytes
10807 bytes
From: Yiran Qiu <eritque-arcus@ikuyo.dev>
ct_seq_show() takes a reference on a conntrack it found by a lockless
walk of the hash table, but never checks that the conntrack is
confirmed. nf_conntrack is SLAB_TYPESAFE_BY_RCU, so between
ct_get_next() and refcount_inc_not_zero() the entry can be freed and
its slot reused by init_conntrack() for a new, unconfirmed conntrack.
The increment then succeeds and the dump prints a conntrack that is not
in any table. nf_ct_key_equal(), gc_worker_skip_ct() and early_drop()
reject unconfirmed entries for this reason.
Since commit 2ad9d7747c10 ("netfilter: conntrack: free extension area
immediately") this is also a use-after-free. An unconfirmed conntrack
can still grow its extension area, for example when an nft ct helper
object attaches a helper, and nf_ct_ext_add() then frees the old
ct->ext through krealloc(). seq_print_acct() and ct_show_delta_time()
read ct->ext without a lock, so the dump can read the freed buffer and
print what it finds there as counters or a time delta.
Skip entries that are not confirmed.
Found with afb-afl, an LLM-driven kernel audit/repro pipeline; the fix
and this changelog were also drafted with LLM assistance. Reproduced
on a KASAN build of mainline (v7.4-rc3+) that carried timing counters
in ct_seq_show() (two ktime_get() per entry) but no added delay: an
unprivileged user in its own user and network namespace churns UDP
flows through an nft ct helper object while reading
/proc/net/nf_conntrack, and KASAN reported a slab-use-after-free in
ct_seq_show() after 9 and 41 minutes in two runs. The same build with
this patch ran the reproducer for 60 minutes with no report. With only
this patch applied to a KASAN build, the conntrack_resize.sh selftest,
which compares /proc/net/nf_conntrack with ctnetlink dumps, passed in
three runs.
Fixes: ea781f197d6a ("netfilter: nf_conntrack: use SLAB_DESTROY_BY_RCU and get rid of call_rcu()")
Cc: stable@vger.kernel.org
Signed-off-by: Yiran Qiu <eritque-arcus@ikuyo.dev>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_standalone.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index d88a10230862..299691d7ac1e 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -314,6 +314,9 @@ static int ct_seq_show(struct seq_file *s, void *v)
/* load ->status after refcount increase */
smp_acquire__after_ctrl_dep();
+ if (!nf_ct_is_confirmed(ct))
+ goto release;
+
if (nf_ct_should_gc(ct)) {
struct ct_iter_state *st = s->private;
--
2.47.3
Technical Details
Message-ID:
<20261130215141.1009148-8-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-374483-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-374483-linux-kernel-netdev=dewy.ru From: pablo@netfilter.org (Pablo Neira Ayuso) Newsgroups: linux.kernel.netdev Subject: [PATCH net 07/10] netfilter: conntrack: skip unconfirmed entries in /proc/net/nf_conntrack Date: Mon, 30 Nov 2026 22:51:38 +0100 Organization: Usenet Network Message-ID: <20261130215141.1009148-8-pablo@netfilter.org> References: <20261130215141.1009148-1-pablo@netfilter.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1547607"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:SmTk7nZZ1WN9kLc6ygXScRS1Kjc= sha256:moxtdev8ki45e6MSx5iD5DtxXmh1KPUqjMq2ictQM08= sha1:3gCIvCk/kId2s9fuA4Los6YX2wg= sha256:3r0ruRMVWHm6h0U+YEGBEh/lN2bd2+mNMKtQXBakpW8= 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 8F69C126007; Tue, 1 Dec 2026 00:52:22 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 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] 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 V4-ZPUMbiZwm; Tue, 1 Dec 2026 00:52:19 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-374483-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id EF3D812600E; 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 sin.lore.kernel.org (Postfix) with ESMTP id 6C0C324E68; Mon, 30 Nov 2026 21:52:07 +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=1796075520; b=b4Z0PzCtBG+7/ETWYVX96L6R+Kp8LQ14NKs8AgQ4dDVGH7bYm5J/XxPKixCz8yrZIb0B WDTfpUtvuFREdJKotkS2rcEbdPNZiX9F74lJMP++PavoZdn2xrMUFgyqvmB+lPyrOi+8q WKT3PfFiWVApEVbjQ86osBQr8oQCgIJKhcsZy7S13uAbW721bI7TsIdC/FzCsSPfPkAmL Rcz6l3Qe7hds7KEdaPawF+6vnH7Lwu6LF6QNqwa1J0ETrxJXREGU2qx47A5Hi0vPUr6TU sD7et2Uqm6yPSbkQiECCvOQjN7/kySVGf8bvNnzds/MFciDmjOjl9IWAcBEu0f6Uffg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796075520; 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=tZfQIu9jznMqicexxLbxozvEsFtKTGoIZqpfz9Cw35w=; b=NAl/5kZXkERLQqy98tB4IY3kvbSTRt0krJAyiDydgIuoWJreo9fU6roly7e4lStEXktr fXAEbo4Er4Uz48Ao67kUAdxoZsNTfquElgGAlh5coIpIRwA5zCNo0LmRB3E3yTkFO8IZU r1elzogzczVmqrAJkPNeCPrmaOQsjSTkc6ExgOoLjzdOFp8qRkxz9QWmw9pvMyeeUs3yk Cg/XK3P/pFZLDeClm83R1cWKWUjUXxugGpq/SDSXGTyfBY3+N83VyWun8Yaq2zx2hM05l AmuKwFDuGH7WttHuk/FBEXW0Xv2lTUCokSsb3MfLUi2KcH/HXpksNkFgipsrWOtYuhg== 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="MV/5v0za"; 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 65B76606A695; Mon, 30 Nov 2026 21:52:00 +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=MV/5v0za 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=1796075519; b=of37AOMg7Vl175DDsCWOMdUirlZ2vBRSkW+yhZfpyFsTTG2uYBWaXxuBUxnWsxQGF9St ZVoazeInQVSG1erFCQU1gcLolM0NG/46xMLAeU8eHxIT4XLAHw86aBxojC0hJJDKv7nJk 6nyN7LJP/yDKjMr4mnhTDPN4wdXioL6QferLEtUKUxCMPS3nToXcdFBrLjZbwvDR4hsSn mFTCnqK9M192SaVcxpTzO9ubBXRHXp+bu5s1TUFN8WBXWHu9zQ9QlTc7r8lUcczyJlvBF Xpfx9DFoPX2aX0lQ1beNKJ/tiyGfzEnlFdHGFEajKUxn13xpaX7+RUIF2y/qNLDICoA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796075519; 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=tZfQIu9jznMqicexxLbxozvEsFtKTGoIZqpfz9Cw35w=; b=ykhzEhSdc1cB32PoI0fHFA+lqU8gLtEwfJA/sgcm7lBuML0U+qx0M5ILTI/JQrp0SSPQ 6sCE+/9dLxtM9eGFmBjeyDkqajrtqDxkBZpmMHicSz3rOsbCJu1ntplwIrUKFZugVeFnI MMn2pmH5p8DdX4lppvZt+QtWZ/eGjXTF4Z0q5p4wLGEVxoe+aFPX7UCFCapcJDaYENwi0 zTN5VxMFkAVTdaEOrRg3LYC0y/M7YVK/K0Ar/lPRuD9bUgTK/phkEQxtk/RfYfoBeoiWi Ng5Ply17uR7ut52hzwAKCiFnPcD2hiSOO1+fudh5gnnPfALXnxhbarQIdaQ0EDjbuRA== 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="MV/5v0za"; 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 1CA5E606A69F; Mon, 30 Nov 2026 21:51:58 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1CA5E606A69F 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=1796075516; bh=tZfQIu9jznMqicexxLbxozvEsFtKTGoIZqpfz9Cw35w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MV/5v0zaS9HMIgOMLF7vk+xg48nH9RSl3D5Bhjfwa5fzbKC5PcCflU2XgUitDcVlD aSfNA3qlDLRq0tjgNH8Ovg7bhwWVgKQHspY94X8WYCrXx6NCs+ubAlKONz9FjIDKTX HXvH4YolyyRDraLLmeVMBJWV6Rg4fsStoB1KTGiK6Tz+PJQ1eiCpkAYXuSFWbpoodG NicMGNRfSi7ILFG9CMpLDgyjhD7ao9BsgQsPOu7m4AIDPoNjX0b1qajW3ODIY828Yw iytr2sPeDu+X/kSV+u1hAhAQno57XjfkI79I7i1a6T0H1ZvK6exo1mC3APk9totidk aXD2VO4IQHryg== X-Received: from localhost.localdomain (mail-agni [217.70.190.124]) by mail.netfilter.org (Postfix) with ESMTPSA id F34A26005E; Mon, 30 Nov 2026 22:51:55 +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