🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #4439

[PATCH net-next 06/15] netfilter: conntrack: fix unlikely UaF in gc worker

#4439
From: Pablo Neira Ayuso
Date: Sun, 18 Oct 2026 00:56
47 lines
7446 bytes
From: Florian Westphal <fw@strlen.de>

When early-drop scan is enabled, gc_worker() reads tmp->ct_net, resolves
cnet with nf_ct_pernet(), and reads cnet->count with RCU read lock held but
before acquiring a reference to tmp.

Its unlikely but possible that the worker gets preempted before reading
cnet->count while nf_conntrack_cleanup_net_list manages to unlink all
conntracks and returns in the mean time.
This allows for the pernet memory to get free'd.

On resume, use after free would occur when the worker reads cnet->count.

This can be solved either via another synchronize_rcu() in
nf_conntrack_cleanup_net_list or via cheaper flush_work().  If work
wasn't running no race can happen as next call cannot observe
already-unlinked conntrack objects.

This is an LLM finding with no reproducer, but it appears to be correct.

Fixes: c6dd940b1f74 ("netfilter: allow early drop of assured conntracks")
Reported-by: Vega <vega@nebusec.ai>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_conntrack_core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 8514a37c29fa..931b76aacd93 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -2506,6 +2506,11 @@ void nf_conntrack_cleanup_net_list(struct list_head *net_exit_list)
 		goto i_see_dead_people;
 	}
 
+	/* must wait for current scan loop, worker also looks at
+	 * struct nf_conntrack_net, which is about to be free'd.
+	 */
+	flush_work(&conntrack_gc_work.dwork.work);
+
 	list_for_each_entry(net, net_exit_list, exit_list) {
 		warn_on_keymap_list_leak(net);
 		nf_conntrack_ecache_pernet_fini(net);
-- 
2.47.3
Technical Details
Message-ID: <20261018005638.1776148-7-pablo@netfilter.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347887-linux-kernel-netdev=dewy.ru
References: <20261018005638.1776148-1-pablo@netfilter.org>

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-347887-linux-kernel-netdev=dewy.ru
From: pablo@netfilter.org (Pablo Neira Ayuso)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next 06/15] netfilter: conntrack: fix unlikely UaF in gc worker
Date: Sun, 18 Oct 2026 02:56:29 +0200
Organization: Usenet Network
Message-ID: <20261018005638.1776148-7-pablo@netfilter.org>
References: <20261018005638.1776148-1-pablo@netfilter.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3186363"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:zvlS9eKnQ/gs07phClGdlEpkOIk= sha256:QSy+c4K42xIVPQyOXvkFKC3UMvUob5+YZyG/V6uqcqw=
	sha1:k03l+aXTApbRh5jfGJL+B0pEfMg= sha256:EB+LHp6ScuVliWLOcU9H4eXJ1FJ90fHMO5fuwEkIeSA=
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 C2C8D110781; Sun, 18 Oct 2026 03:57:31 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 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.25,
	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 XT5m8RxHYo40;
	Sun, 18 Oct 2026 03:57:29 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-347887-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 1C719DF0B6; Sun, 18 Oct 2026 03:57:20 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sin.lore.kernel.org (Postfix) with ESMTP id 380DA2C23D; Sun, 18 Oct 2026 00:57:00 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id CCAF92F616B;
	Sun, 18 Oct 2026 00:56:59 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.b="KkRcS+VA"
X-Received: from mail.netfilter.org (mail.netfilter.org [217.70.190.124])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3766B2F9D98;
	Sun, 18 Oct 2026 00:56:58 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.190.124
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1792285019; cv=none; b=XtnB5v/Go1Vb3veciCgUGjqxwJ0TWQgrLK801lEcsLdENmlD8HyosPrzZ572JJ6YO19/XHryiG1xIEVrSisvGQ1C0oSpOMU7cb/n5gN5PIzWhxIqGbXxm2BuwtANu7Eq8SaMVll0KwlJClSYZn4mjiVjfOLO0iLcNfTAPdWUJYw=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1792285019; c=relaxed/simple;
	bh=jtnd1kT+hcxvpaSXSmEOS3BEITf6Sl1ZFwsjVTGdGsA=;
	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version; b=BBM93AY8iJEYvMQxKQpFFa0uNAMAUy/qufwgQGKGTFv5Lkz+tbJuSdbEzo34QZ+c9lfM7exwM+dNScYdvfOCVUQFu6ubzl9BMZipfwNXL6y0qi/ll7x22uyYcd351rX1wTZ1z9abmGxGBw4G1q0t60mKMW3EIu6LDA8aIn8tna4=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.b=KkRcS+VA; arc=none smtp.client-ip=217.70.190.124
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=1792285016;
	bh=TjT0fdPnrkdpxQaUMKe8SHS6swdSnTSf2bWiqDmLhoc=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=KkRcS+VACQGm5TLYdMaqEsBOGBE+7btvc5WBG4oJ/K22wd/n/p8NMgbsUX3R0dmLG
	 i035+//qfJWwEbUgaQwJQLzdeQxmq/zHzVeCFf0NfaThr9lNDhLnP9gB+DZ4Sl8mry
	 hqzYMUpaGV0p6Zc4IvELZ7qWdYFztRJd8oG7Y+doySXG0IoBlqafPu97HxYRoYxKPk
	 jseNGEwN+rL1TNpUpQM1K/bB4tAtPu25YejuQwTYA20GqWQXd/LMfgNrPa8jRz45cN
	 WmrI8la4UgtPv1Uwjh9XPcw+MqXCrCl/EanP0LSg0sygduZoMConN1UezMh3gGi4fx
	 EBi+EOsxzZr8Q==
X-Received: from localhost.localdomain (mail-agni [217.70.190.124])
	by mail.netfilter.org (Postfix) with ESMTPSA id EB44260077;
	Sun, 18 Oct 2026 02:56:55 +0200 (CEST)
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: <20261018005638.1776148-1-pablo@netfilter.org>
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>