From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.47 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== 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== 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 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 ; Fri, 4 Dec 2026 07:30:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D7E7A606A322 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=I61BIXOh Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-3b51a9606e8so342196a91.3 for ; Thu, 03 Dec 2026 23:30:21 -0800 (PST) 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) 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) 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 v3] netfilter: nft_ct: reject shared conntrack extension updates Date: Fri, 4 Dec 2026 15:19:02 +0800 Message-ID: <20261204071902.36828-1-alex000young@gmail.com> X-Mailer: git-send-email 2.56.0 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