🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24013

[PATCH net 07/14] netfilter: conntrack: skip unconfirmed entries in /proc/net/nf_conntrack

#24013
From: Pablo Neira Ayuso
Date: Sun, 29 Nov 2026 00:07
59 lines
10844 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: <20261129000724.797425-8-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-373304-linux-kernel-netdev=dewy.ru
References: <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-373304-linux-kernel-netdev=dewy.ru
From: pablo@netfilter.org (Pablo Neira Ayuso)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net 07/14] netfilter: conntrack: skip unconfirmed entries in /proc/net/nf_conntrack
Date: Sun, 29 Nov 2026 01:07:17 +0100
Organization: Usenet Network
Message-ID: <20261129000724.797425-8-pablo@netfilter.org>
References: <20261129000724.797425-1-pablo@netfilter.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1064540"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:SkKBoiqM/5yBL+1seqwSfdE+w+s= sha256:5YYLTZ//7lf2boa5oHn6GkiWE1AX7HLLvTqmye3RUwQ=
	sha1:UsNhrB35fggnzs+39ccKfxdwfRk= sha256:uxmUw2krhosVTaPcDh4Ogp0570xEmeAFCb7JYI/52A8=
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 9E136125F88; Sun, 29 Nov 2026 03:08:16 +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 9ixCyo1H_r5a;
	Sun, 29 Nov 2026 03:08:13 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-373304-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 B1CD4125F8D; Sun, 29 Nov 2026 03:08:03 +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 2381B28A27; Sun, 29 Nov 2026 00:07:49 +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=1795910863;
	b=t6ps4GIjRUhSQjnGgamzPi8HkC+OtlTCpAnLu0FT3FecyRF1sI8L/0XIZKf3LkUfLs0U
	 6C6hGZhiozem51LlxFCs7/UHGl0KCpOHOj7O34KYGEB8k0fvoUIwCSsRIvrjryGRvxS7V
	 p1x953oHH1dFHD9hoWYdTlT0tbGsRCxiIDJoa2iQY5hjy9lY50ZDsurhZmusFQhjA9jWl
	 Gk6daeygBeTNPoC7iC+BaRBAXkLRFfTXAdsQFM4tXnyTowZeVO8oGfooCtACn5zC9iZ72
	 rEfgShxN4Ba6V4IPur9Rfq+izMHAYTR6T3wHw7RV6TpvPYeXxHtxhrk3UN5btIL1w8A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795910863;
	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=VMSD7FW8NAln8gpTqnDnSpqVeVx3B3xedNGGVib48AWNwI9KWBUVz/QkfqP0mnpeHEyq
	 WWJaxYoE9pHcC9Lh/zRKfWt3FNU+TLJrZYSU16azTe/NFPottjRm/dT6aKn4SRo4GUWlU
	 Vxy6cs/Jm0j4Q/xyn70RXMx5bl/wHgCbmqhLnu8WmHCsd78mh2KRnJa8CIoZ0n273QP/q
	 DsnUlZCGqU0Iy8CfEa4VLwYr9ZwDbvn7nHSWxwZLNKDFJON+4aF/BXH6dzTjGrRpVaXKr
	 lkK5k86mmDdIzfmSeFreT7Opf6Xlk02UFnUYzpBVn964IdWr3VTSLy4162Pjk9VYScg==
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=ddVFEQu9;
	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 74F19606A33E;
	Sun, 29 Nov 2026 00:07:43 +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=ddVFEQu9
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=1795910862;
	b=cgUACrLYhr5Mp57wpEE8bGp/3EyQ6drjvaYZJL0OWkWTV7eS+OCrhOndZj5u70/52Rs3
	 FyEq2ZXTQQ59Mi8JGPv1pRY9LvayvKLDFaOwhs95JihvqbK3fNOZ6Iy+v0Dhp/fXEtaAU
	 2ICsfueEgKTjQlxT7c9AHosgRJLcCK1iqvm55MqiWQAQ800GAd5IRmnrLwrGqnBZ/05rx
	 wB7vh+Mg/LC7C5iZICzzAynujt6N774Ovsu+H1+gpjel2pfMwZFjeV9C75CbMpzBOE8d+
	 g4OqGY3thOfdKBQE19kDFZ5Q4mICcOHwob/aWa19a5JYZGqA/QrOD41dG1yffDAxPsg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795910862;
	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=G2qIIs9fraEwruPSJSIESHprSU8R0eLNlSiEAelIluHMhcTtkYuegKHushWikYXn+fZ3
	 +Pk4izTADffY6LqLm1hwjcM4NR6hMTczkWVGqi6aRHLAI8I2iapLHFQPflW6SF5LvSMI0
	 MXD2YT10Rsh0EO8RepPyMn6OYMHEvzXnW8OUzNXalTsBq2Nq2t7MHpvwPrhNd8RpOq/YO
	 EWOhp+r61OYtlqN6vUZM22nZdHyC79XzfWqLeqQf2RfjqOAFsw9gli8eT1p8RWHfyat+U
	 Hqkh9FA/VuYZ5jOX+pltc3X24htJpVUPZz4DoEVnNvICfOvcy6sJ04pRUmFWPOJJ+WQ==
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=ddVFEQu9;
	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 262A1606A683;
	Sun, 29 Nov 2026 00:07:41 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 262A1606A683
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=1795910860;
	bh=tZfQIu9jznMqicexxLbxozvEsFtKTGoIZqpfz9Cw35w=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=ddVFEQu9lDU0mNrRPMAObCo9FEu0nsc9XxsxGQal+y/9WQ/pOX7zcKqyT1/ckuptk
	 TW6pkqIYqTPPAo5sgc4R/Wfb1REJ5h3VXZgkQJKg6ROqOknRPhd5BiJ3lLh1XZNevH
	 0oS7XwZpsiHtgLqM9K+zOI/fl5DQGgtdDy23D3Q6ACjUtBMLv6IEZ59yVQMPMr8XiI
	 DthV01rBD6e802R/Q8LyanWYrM0EYTgX9xSlF4U2mbclL/yCBmqmkPTr0DzT1NhVVp
	 aNljs5C99OYcCky1bVURm+Hk5zi1pMwT6/FyuF7+iTZScx09iy4ocs17Zq/dnclYyk
	 qlTMxIYNSGLhw==
X-Received: from localhost.localdomain (mail-agni [217.70.190.124])
	by mail.netfilter.org (Postfix) with ESMTPSA id AA3DD60082;
	Sun, 29 Nov 2026 01:07:39 +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