🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26812

[PATCH v3] netfilter: nft_ct: reject shared conntrack extension updates

#26812
From: zhuorao yang
Date: Fri, 04 Dec 2026 07:19
115 lines
14740 bytes
An unconfirmed conntrack is mutable and assumes exclusive skb ownership.
Cloned skbs can otherwise reach nft_ct extension paths concurrently and
call nf_ct_ext_add() on the same ct->ext. Since nf_ct_ext_add() uses
krealloc(), this can free and replace one allocation while another CPU
still uses it.

Reject packets that reference a shared unconfirmed conntrack before any
nft_ct extension allocation is attempted. This covers helper, expect,
timeout, and event-cache extensions without adding a lock to the generic
helper API.

Fixes: 1a64edf54f55 ("netfilter: nft_ct: add helper set support")
Signed-off-by: zhuorao yang <alex000young@gmail.com>
---

Vulnerability report

Affected versions: Linux 7.4.0-rc5 at
  fe6ff8d5d675c01793b9f051d16055dd4aa75244; the helper-set path dates to
  v4.12.
Trigger conditions: CONFIG_NFT_CT and CAP_NET_ADMIN in the target
  network namespace. Two skbs must share the same unconfirmed conntrack
  and execute nft_ct_helper_obj_eval() concurrently on different CPUs.
  Existing accounting, timestamp, event-cache, or label extensions make
  the helper extension enlarge and relocate ct->ext.
Reproducer status: A QEMU KASAN harness forced two CPUs to enter
  nf_ct_helper_ext_add() on the same unconfirmed conntrack with a
  104-byte extension allocation. The unpatched kernel produced a double-
  free in krealloc_node_align_noprof. With the fix, 1000 synchronized
  two-CPU iterations completed without KASAN. The exact shared-skbs
  network path has not yet been shown without the test harness.
Reproducer material is intentionally withheld from this initial private report.

 include/net/netfilter/nf_conntrack.h | 10 ++++++++++
 net/netfilter/nft_ct.c               | 21 ++++++++++++++++++++-
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index c39425e54d87..e6c47178af5b 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -271,6 +271,16 @@ static inline int nf_ct_is_confirmed(const struct nf_conn *ct)
 	return test_bit(IPS_CONFIRMED_BIT, &ct->status);
 }
 
+/*
+ * Unconfirmed conntracks are mutable and assume exclusive skb ownership.
+ * Cloned skbs can otherwise race on extension reallocation.
+ */
+static inline bool nf_ct_is_unconfirmed_shared(const struct nf_conn *ct)
+{
+	return !nf_ct_is_confirmed(ct) &&
+	       refcount_read(&ct->ct_general.use) > 1;
+}
+
 static inline int nf_ct_is_dying(const struct nf_conn *ct)
 {
 	return test_bit(IPS_DYING_BIT, &ct->status);
diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c
index 5a8db5592036..5dad764fb576 100644
--- a/net/netfilter/nft_ct.c
+++ b/net/netfilter/nft_ct.c
@@ -323,8 +323,13 @@ static void nft_ct_set_eval(const struct nft_expr *expr,
 			break;
 		}
 
-		if (ctmask && !nf_ct_is_confirmed(ct))
+		if (ctmask && !nf_ct_is_confirmed(ct)) {
+			if (nf_ct_is_unconfirmed_shared(ct)) {
+				regs->verdict.code = NF_DROP;
+				break;
+			}
 			nf_ct_ecache_ext_add(ct, ctmask, 0, GFP_ATOMIC);
+		}
 		break;
 	}
 #endif
@@ -891,6 +896,10 @@ static void nft_ct_timeout_obj_eval(struct nft_object *obj,
 
 	timeout = nf_ct_timeout_find(ct);
 	if (!timeout) {
+		if (nf_ct_is_unconfirmed_shared(ct)) {
+			regs->verdict.code = NF_DROP;
+			return;
+		}
 		timeout = nf_ct_timeout_ext_add(ct, priv->timeout, GFP_ATOMIC);
 		if (!timeout) {
 			regs->verdict.code = NF_DROP;
@@ -1143,6 +1152,11 @@ static void nft_ct_helper_obj_eval(struct nft_object *obj,
 	if (test_bit(IPS_HELPER_BIT, &ct->status))
 		return;
 
+	if (nf_ct_is_unconfirmed_shared(ct)) {
+		regs->verdict.code = NF_DROP;
+		return;
+	}
+
 	help = nf_ct_helper_ext_add(ct, GFP_ATOMIC);
 	if (help && refcount_inc_not_zero(&to_assign->ct_refcnt)) {
 		rcu_assign_pointer(help->helper, to_assign);
@@ -1429,6 +1443,11 @@ static void nft_ct_expect_obj_eval(struct nft_object *obj,
 		return;
 	}
 
+	if (nf_ct_is_unconfirmed_shared(ct)) {
+		regs->verdict.code = NF_DROP;
+		return;
+	}
+
 	help = nf_ct_helper_ext_add(ct, GFP_ATOMIC);
 	if (!help) {
 		regs->verdict.code = NF_DROP;
-- 
2.56.0
Technical Details
Message-ID: <20261204071902.36828-1-alex000young@gmail.com>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!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-377153-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!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-377153-linux-kernel-netdev=dewy.ru
From: alex000young@gmail.com (zhuorao yang)
Newsgroups: linux.kernel.netdev
Subject: [PATCH v3] netfilter: nft_ct: reject shared conntrack extension updates
Date: Fri,  4 Dec 2026 15:19:02 +0800
Organization: Usenet Network
Message-ID: <20261204071902.36828-1-alex000young@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2703344"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:eAE+UE+y9iCxuJ0iggl8Zq1BdNQ= sha256:aMgs2aHDkL8kggBpQXeYdTBsOxv2GTH/7uGWJjyUFIM=
	sha1:ubAK0hEhynh5KAas2dOmsiZQJuY= sha256:IIuGWLePDAcbQMdEc8VV4MagcZqEGXCpGkOldJWF+Ds=
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 D5928117B50; Fri,  4 Dec 2026 10:30:37 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.297
X-Spam-Status: No, score=-3.297 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, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001,
	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=gmail.com
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 rjtnROPTufTr;
	Fri,  4 Dec 2026 10:30:35 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377153-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id A7527117AFF; Fri,  4 Dec 2026 10:30:25 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 4330D265D5; Fri,  4 Dec 2026 07:30:23 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796369423;
	b=kfJGt/nDKdaojFZAUGV34ogZGJHN2/svM+Dj+oVFaObG90OP+1jsZ1X/t23InPGxjzqQ
	 16h2RvFOzl4iZ1Yf8SMvVydW3Bxn2McUwbaHI8m7Lx/QcchQpbSNklK9+RWpBnFcEDXtY
	 joDvHP++2Z/qisyUwL12AiqEQoUImjzSJoVkJG9P73jxIxP+030LiZIXCJjR92U8Uwet6
	 dw54CRJYSkAKBsV9X+sDQVV12hqOI6NLgLZUyUCQp4sW94dmVvbBqRcJFCnm2ik4gb3Uy
	 jTSwJb0gTAoQitMaHZDF4Cd/2Us3+AXq2C5EEatS7AGLQ03FHG3WE7YVM2JxyFp30Vg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796369423;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
	 X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID:
	 X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=WR5Z5Urwum5NGTXkWto3ooii4zfEHe8Eh4Lwcm1cOVk=;
	b=zeOvvwHpAnJz49XqwMFv3Wcu5ri1CQKmLMHVmR//E5TzVaxXNDiIVv4XmRzhhQ9hHlit
	 ocxKECBOFUPHKadHTU9vTD6PcJWNxCRch0luFbyKW6xp6edg+2YA4KcucYTTnux6A/sfI
	 QqjxdhMYFeTVWHHuHyK8E0WAYjkDfwrxRt4iS81DtkosIyCzAg/xM+d+Wlklxli096Fwi
	 1qC9YarHUIE9hLrSnh77AVQVyCmb3uILlQPq67qbQmkzGZqpUSUSQ4fTNZm8VXDGnPc/y
	 kv770ciIvHhEUGVsGgC08bvJEmJkPNrtapWMF7/XZqHBy0SWrO3cAOCZNHa+7lLl5IQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=I61BIXOh;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 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 0A604606A338;
	Fri,  4 Dec 2026 07:30:23 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=I61BIXOh
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.47
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796369422;
	b=px9hCy5NpJmZlzlSejSR7VISjL11qdaoWSTXsbVzamYnHsCgPaTWXDsbbz/tZ9qCyb3C
	 /KmVVzj9qYJagB4Aam6Pnkpf/V1GkIVNj35i8FYS8fi5ZjKsO2YAtZ2ypY/p2mb8S1gdd
	 aA+uHxi6Dk7i1GiqNPFDJuZDlT3Yd6m33FaFuy4eLkwWDEDxj7S/9Qpw2q97hI8BNXxU2
	 A0het8XeJ/ntUeuURlW080IuY83/JjnHV4e56oZdtKNrFBpjyX2zlXztUjjV6DOsqfE5O
	 4ALJ7H0yksIZgsOAiTDtN5KpJx86AExoXCDGjY/v1lgoboTJfk+gFtM/gAqf0lZqQBw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796369422;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
	 From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=WR5Z5Urwum5NGTXkWto3ooii4zfEHe8Eh4Lwcm1cOVk=;
	b=xXklrBpzsrrHoUwsTYLjifVzcKRavKxnTW8wB7iNAYIvfvd4BN2bp05cous7Qtv6bRnH
	 PSXj/ZW4wpPu+i0xs49zjsch9+9Vf54XhL5+33KAgMYhGCGZyOxIqztNZ0Y8D37t3U8Gk
	 2Ztc92Basyu+WeOKT60l3Gb4YxPDTJwmd0bz3hpfoE9Q44d8Qw7qhHsAwVtyRCuRIyL1S
	 s+aYNclIUnYb+64miuJAV5K8aY7VLO/5xetaQ92gR1qR9yhL0DyA8YNchjZL2Cj1JCn5g
	 MgdY1XVG8nintd64mTKzdS0OC5zeKowJjFTAwQ4NAQ5b11jFNRZKNAXFeMHgllHEv9g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=I61BIXOh;
	arc=none smtp.remote-ip=209.85.216.47
X-Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7E7A606A322
	for <netdev@vger.kernel.org>; Fri,  4 Dec 2026 07:30:21 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D7E7A606A322
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-3b51a9606e8so342196a91.3
        for <netdev@vger.kernel.org>; Thu, 03 Dec 2026 23:30:21 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1796369421; x=1796974221; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
        bh=WR5Z5Urwum5NGTXkWto3ooii4zfEHe8Eh4Lwcm1cOVk=;
        b=I61BIXOhYKVgTgqgJ1AM5wbYjQDqctBZHBhE7rEVSN9TillVY28mQob978v4mHwDrT
         8ZT83BjC6oLXqNjiLx5chP7OzkS8vryURpn10+E16RV3Bd/7JLcADdJfFPjAEbXD/JMT
         UFvCa9zi/wxpvPKejTBf+dMHKRWeB+qz30mdy/eqbw6hFwGsOHTnRKgQ2a3L5k3CEDkH
         kqaGe1iIqKKDR3yZ3jmtpXzB7Qpv/mYaQkELJz/Y1fQV7okSONoqWMlpcAOJoeDudUyo
         cavVTAzopHOya1fyyuYFXFzllh4FL0zLlWjfDKVRnCR27cL8pCoMpBuRtodw7+2GMMoH
         fcTA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796369421; x=1796974221;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=WR5Z5Urwum5NGTXkWto3ooii4zfEHe8Eh4Lwcm1cOVk=;
        b=bOBJLlYiT9R4pmEiV3nXJc9MEpjvXXeUCFvrw5zzzXPtTdzHwu3//NTN1rI0XfWeqr
         0dn3Y6345V8qBr16yLOPEsekWWc8O1hyUWv6TjC+rqc87tGhB/YQskj7XCCKYAjbUCni
         2WudmzVSltgxejvMTgNUOkMnPt9yNDMmFAiGwGFfq8MQlpbWZRo+o+tzLrdZObFcNUR5
         3yKyhKLYMSmc0ginQ4trL6HuHZCaZLW8lREFaZhMUZO9ZFBq79GJMVvRDTlAyGR2d6K9
         Vgpe5R06eLCyoZGny27QQcJKSd/N1iEuvoqCZMmacSee2y/4xxp/TjaahKo7Tr6kC54B
         R4cQ==
X-Forwarded-Encrypted: i=1; AL+hErH5MQw4dXg9l+I6dBPSG9UhL8Jfd0IjZkNUNSbKGC2g+vYUMQz3UCXYcFgR5sSRe8vZK8B2dTY=@vger.kernel.org
X-Gm-Message-State: APuU4Z9wM3yeZjCtQp6xMr9N6JrdcgOW0wxRlmEyYvTyFARkkLR+nsKD
	np3de8zoWErexfBIfUYh7fazffkmk2dZ/E3aI+i3HwPcD2dRauKws71a
X-Gm-Gg: AZFdTZe7AHheiw2eh6ci6d+HjvCJnq2rp3FZiTPd1xazF8YfTYGQQk7V+6LBRqjojEN
	5znapwzZkrukXvXBEh3bZVW6E0jZfGm2ZuR1tUZsWAJWrPxJ7LKuDaopnccE3BtvRM21fU/a2hO
	Of1Gf+KA8AJrRTm24YOj/CGbW0uoSrJxEFq7veWvAaajvTtnsyEW1pGORaSYACBDxXyA5GNZkpG
	ynu/MsGL1nk90I/gswfLWYva/d3i/OdbYJ7ip3BYmi1R5A/c9tnJp310cp20U16MSCVUjNeWPyi
	SFUdgLGvvep0oxoL5GLIzP61mT8Asp6tTDA9f8cn58wboDwoY9jTJ1ILU3A80p/SM9jGckKoLeI
	sUC0YsQjf4bOWeLs1BmT6z6ERmDqpWxaQBb562MYPW+xKsnSPe1F5wbIUoJv+3LJcLQ+sqhw9X9
	DsPLHoHZLk8pFHfQ8f1mwFlRq4s3O4OlgVfDPR+9rxkRzPWZkVuzcw0bkI8v7+Ci2prlIZ+i9w8
	JUj2sG4zZe88gR0Eapd5V+uK4SjbGzLtuI/35W62N0eQooJCsPXNnDlQQ+RG3el4TKhcvR55Hfr
	zPNEfhtMkoNgIo+gBU66BFTII6iWaoCjuxJhKUrj/V/lJTxp8KXqYp0=
X-Received: by 2002:a17:90b:5887:b0:3b5:776f:b4e8 with SMTP id 98e67ed59e1d1-3b5e06a6a40mr970265a91.65.1796369420774;
        Thu, 03 Dec 2026 23:30:20 -0800 (PST)
X-Received: from [127.0.0.1] ([219.152.236.33])
        by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5c7d10dadsm7966161a91.5.2026.12.03.23.30.16
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 03 Dec 2026 23:30:20 -0800 (PST)
X-Cc: netfilter-devel@vger.kernel.org,
	coreteam@netfilter.org,
	netdev@vger.kernel.org
X-Mailer: git-send-email 2.56.0
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