🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26815

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

#26815
From: zhuorao yang
Date: Fri, 04 Dec 2026 07:33
115 lines
14978 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: <20261204073358.67941-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-377156-linux-kernel-netdev=dewy.ru
References: <179636957458.3305.6694386152606528641@kernel.org>

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-377156-linux-kernel-netdev=dewy.ru
From: alex000young@gmail.com (zhuorao yang)
Newsgroups: linux.kernel.netdev
Subject: [PATCH v4] netfilter: nft_ct: reject shared conntrack extension updates
Date: Fri,  4 Dec 2026 15:33:58 +0800
Organization: Usenet Network
Message-ID: <20261204073358.67941-1-alex000young@gmail.com>
References: <179636957458.3305.6694386152606528641@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2704335"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:4gTX00eEfZmu6BJhzzxVNCYaRMs= sha256:Ee4hhLg+57ScB7FUNdWrWFwDYM6220v7w3r7mfVgCjQ=
	sha1:K9EBs2SOnDNTYkdtULuPrbbT39Q= sha256:R+zWpErrFJTYb8f78gAhVix9+bzjvdgBllxOgDSJtUw=
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 47F40117B58; Fri,  4 Dec 2026 10:35:29 +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 dVoB038kqgqv;
	Fri,  4 Dec 2026 10:35:26 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-377156-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 4525E117B57; Fri,  4 Dec 2026 10:35:16 +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 ADBC221A76; Fri,  4 Dec 2026 07:35:14 +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=1796369714;
	b=I+6VHzFTQM+0pybUSxPsEuyJuc7LPCtB97ftshw6vE0uuDjZZxklMb4Ek9TFfvzKXd3L
	 N2syoqcy2qxStw8Dzi1/8+r7j8ao633Cwkan4lz3FVV4nQNlsn2PCR8pXRXZwx1f6KQP0
	 JNbRFusvC7rv1Ul+z2wCBezXWg/OO2dh8Zex5bcMPwUv8K/OjKbIFSS+xLRneOYnkC2hR
	 1YcVsNjtwn8TATctq6BpN/1yepZbsRK1vu8B0oAozTcCZRnqyeXJHN7VeMxnxKK34S0fJ
	 3HaP/nI+xyfYO5byFUjsGPXepb+ikblGT/I9EpmMm51c0e6hdE7ZWG88iKfM7SAuijg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796369714;
	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: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=WR5Z5Urwum5NGTXkWto3ooii4zfEHe8Eh4Lwcm1cOVk=;
	b=zdXSwcjuA/7p35Bn0zLUnYMmLVOoi9+febkjkOMYJhIShd82ETghtvMV4GbumjeCmbl4
	 SHN6pm970XJMYDwDvPAklGD4nMzfD558+fY67zKp1W9Hs+rEGFlcP5S/xO3HipnoMN8Dr
	 Joa+EX8kfFzY7vrY4U4qacuoc+C2O50jsnN/ojeDmoPsw28+3KOO8MmnGvyRHVaFO24tW
	 WJQcO+c+DqsavnbZ6E51wwa54ZpK+zwPBJwKaA58LkuT52ZlqBabs/2ziewAYtdZGVPxw
	 8uxhF7JPJCP+dbmnVi/3WohfEYPmnGWjNhlHcRQPLAWZEYVWW9DdZAxjXuQAge0q4nA==
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=QMgXSbNz;
	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 4D948606A337;
	Fri,  4 Dec 2026 07:35:14 +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=QMgXSbNz
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.173
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796369713;
	b=grDO2nmhyiy7DdTRCstrcbAwG6+Wh20lLt8/YqbVsDPIsyENSH17vKUwgBO/nNToKzH4
	 Dd8stUNC9sl81qWfxAf3nywCuUMo+WP3DTLFm6L1fesi1FxYKlezUkQQ32FErbef3Oh10
	 SrIULEslFVY3Kpi53Z+uNGUrznQYVqU+NBe/DRWV0zLJAv+bFeYSZNHewumP3GpRoOSyK
	 W6bWBYm0vtPE8e3Uenlqc1T19rSfF4nfvZXZYCqBUoHsWQSNjpG/u3F3Ee6vUz9jQI2KQ
	 I1gCnGzZRC9R9ESWK4brlnh3YKzEAqUdIfV1cChwgdHKNX7164BO67jYjUS7OSIVerw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796369713;
	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:In-Reply-To:References:
	 MIME-Version:Content-Transfer-Encoding;
	bh=WR5Z5Urwum5NGTXkWto3ooii4zfEHe8Eh4Lwcm1cOVk=;
	b=hGIsxgi/PPBVlaBGJ9NtY0oKeshzvFsZoHYU/1OZ7FJuYdDTY7uXldxAhSMlqqnjn9Mf
	 YUicHAIDTetf8BHubYTSLcG5FIOewsiTGfk0ruJiMFNJ3FhclLJDQ98KVmrwXV27Wt5CH
	 K4ah5aYCgYw+wJOpNR0+V2xrYUCEJLM/eBaEvGAXswdeKv2G9P+/8YIogD0UB6m/Cwrhd
	 oSg2sg9RIOfKcvKxvH7S7G9i2D0mfwLzlqcAZ87H7AasUTJk580WWitIY2RBxyEsb2M0j
	 +TvtgDw6WmHiY0y81PeOgw7xWvnS8eZap4q9rOwHPyYxjfmZ+4g9AUF1eP2ngFQ6CUA==
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=QMgXSbNz;
	arc=none smtp.remote-ip=209.85.210.173
X-Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173])
	(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 8A353606A322
	for <netdev@vger.kernel.org>; Fri,  4 Dec 2026 07:35:12 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8A353606A322
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-pf1-f173.google.com with SMTP id d2e1a72fcca58-8c6c06b3321so259311b3a.3
        for <netdev@vger.kernel.org>; Thu, 03 Dec 2026 23:35:12 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1796369712; x=1796974512; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=WR5Z5Urwum5NGTXkWto3ooii4zfEHe8Eh4Lwcm1cOVk=;
        b=QMgXSbNz1NOzCNpisYCRnliqxQpimQHltyx7fR+dMUajJSeoKpAIYDOJECVGUOmYwp
         C2Hm78mgOUI+cafFAWCRjAnDZ92nTtDH4HtANrIqA/YJQn6dV/N2UgVhe33mHLEvnUHs
         REQQAwirq0yFSEoqffuPTcFLh2DMcj01tyP2SqD8wvqGUwMbJSRdUq6d3WeRNZDutZO3
         d93RasDMZza1zSiA2/Fu4hYoxsXUmINuC1QfhnDNQ6U0b0rSiqfr9IUPgGt3V7cSTkUJ
         ajAvTiyYYRGqvdA5Nr+R0yDzRj7ZbIm8MD2dpx+wj7Gtm5Z4w4WcqPV6uBRpNnzDFZ5F
         BZQQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796369712; x=1796974512;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :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=s8uAIIa2pWVdLSai2F35vh08EuqVrhI5Cz1ah8AvILViG3p+gI/3waTB9A75so7YWF
         ybBGlHRpTRx1BpmiljviyBQGLVa7CKeaoNwZIllKsUHLL/sp9Q0IXGBICmMuJEVgjOVK
         MXP1qmd4kTsLM2aD+uFV08aF2gLVUmnzacq7n+ii1kOOzKalg8iwSXByWmMACnPL+c7V
         50Oyjf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:90b:4c88:b0:3a6:e901:e79b with SMTP id 98e67ed59e1d1-3b5e0649952mr1081343a91.15.1796369711442;
        Thu, 03 Dec 2026 23:35:11 -0800 (PST)
X-Received: from [127.0.0.1] ([219.152.236.33])
        by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5c7d7a6b5sm7792690a91.14.2026.12.03.23.35.07
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 03 Dec 2026 23:35:11 -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-In-Reply-To: <179636957458.3305.6694386152606528641@kernel.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