From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.173 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== 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== 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 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 ; Fri, 4 Dec 2026 07:35:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8A353606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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 Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-8c6c06b3321so259311b3a.3 for ; Thu, 03 Dec 2026 23:35:12 -0800 (PST) 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 50OyjfCtuzOgVfKOiGDmiVwPCqiHscfTDUu/an2RWZaE9Ly4bdrkefbc/qgyTjFuEp4y apO+RKD3rwWNFn/EWK6RTtRsWPT/dEZtzv5QluKy9rCxHguLsEbWgAXRbPrsEpa4i+kM +g2A== X-Forwarded-Encrypted: i=1; AL+hErH1GmQX2l9YFelNDGA81TRaQgwtExXkfzc7KkhOO+zaMvhyb4HmZZSVQkmHEM9IlGDoUgkBjqw=@vger.kernel.org X-Gm-Message-State: APuU4Z+aUQzZBAupYJyLbnWyhGFlLB7fpW3xrdqkaIYse7IS2tKO6gaD mI0nDnB+xhK3oZgc8iKwhp32dfVSqeNzcmADizPGm6PRSYzPqzbvDZKR X-Gm-Gg: AZFdTZfDD09SC3/zqw6WVhgGBLzm+gt60Fk3j/MX5xJHxIK4O2u3QYT35TwhNjjM5dT P8niR7BTfJLfB3vOe72PFS/DnL5hWTpduLa7t3MQ27WgB+C0zyvwuOA7CXingNYuKIb/uXl/N6n LqEyC9fMLhKVPTAaBkf5A0zsuvW02HP3yP1Jz4AaYTEmGTvsnsV3kiHlo9ffVLc0dacgdHvmQfb dsa0DaZceeZzr2Ai/CrCEGT5DhDn3rryjcy3+lLFW7MzrdKvteHd7GJvcIw2+hXiXrWv70Kv91d /Qi0B3+aSNMC7KzWdklhhbaVRi2NRJ9/OqQZ4Nbv4AvhCrbqu91Y4pqq358DT/JSOkjLeKzuzeI 6zCWl7aPcc/xsTIk9jk4icDYxBPKgUQx+fAaeSoVvZZVsaL9uPBNPzcbPyoGZaD/Cpy3peiXay+ y7CzGLdx/CyhkbQz9XzdlUBhCShonCx89v8CF/dcEr+fUu3fE62hY6a6Abl6X1Rzw0LFCanimOB 16vUZPLlOnJF3Rr3Z9NyVIZPT9j9P6UExybgcRIQ3UPx3Ws7mLFZOIxAKAnrssgAK6pNxb53r4/ 5AjE18/1+gazjkla5aRN57k7ytcqQLGr91IuKPoRoZCNb6ntvhHfWP0= X-Received: by 2002:a17:90b:4c88:b0:3a6:e901:e79b with SMTP id 98e67ed59e1d1-3b5e0649952mr1081343a91.15.1796369711442; Thu, 03 Dec 2026 23:35:11 -0800 (PST) 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) From: zhuorao yang To: pablo@netfilter.org, fw@strlen.de, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com Cc: netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org Subject: [PATCH v4] netfilter: nft_ct: reject shared conntrack extension updates Date: Fri, 4 Dec 2026 15:33:58 +0800 Message-ID: <20261204073358.67941-1-alex000young@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <179636957458.3305.6694386152606528641@kernel.org> References: <179636957458.3305.6694386152606528641@kernel.org> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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