From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.179 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796115745; b=LzucmK3cuomrxbtaqnxLvbCnNavtV4206qgzlUjrxHiCgbHXJRKc+PhNI8I8JKgdzwQA atfiQIcfrIEATOoSGN4ODp418XMo/OWygqliEtLIlasrs4Evb+t/9ZuFzZnXtKPTKnQb7 n/noXYluXh0eENE881TZmsGli2JD+XCDRPdI55eZQRrmirmQdEebM7j+aVfmw3AWdGuez 9xme70FWzc+4CGL9RmMRDI0ApYkwQ3UXe+30KCq325SwryUJfgfYoNBjMvV7b/0AAMYYD OEcEo+hAdRFUlAwXhtJgVMGAZ+PInZTVGsbQPRVBC7oaLQmFEEWSDvvSHICiamks8Rg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796115745; 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=sL37OI+fW7/naMTi+7AppvVUyo6nvx9cHdphRMAiohQ=; b=f99wKBof8bSeBZ740lz89TIIJ8HZf2tQ4VWps93HE4WzTpqerBIQFfYS4QPOOudbLY7k /+d1Pa8bISvXOcb4mMpNmNn+sU66uBr18KhIqQff7KikPaWCMCTilqbaI2iB34QSHye3n JtzKOEaEOoLy3lxgcb8RznG4gi27PjPJVGJ4UNb2Yrk5gqlNbfSnkzvNPgYJRJGo8RTZf NighSJbgN0HaUL/ZXB4Zfzow8ljVR0rNUVLliROajCTrhRyYa0wzABJzGuGkkbKsz1+oL l7jSJLE90Ej9EH2XpbET9LmqRfL2/pKAHC8J+0MQBxgC1aultgIEyYL8MvAqIRUUACQ== 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="k/9y+p4A"; arc=none smtp.remote-ip=209.85.210.179 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (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 B88E0606A31A for ; Tue, 1 Dec 2026 09:02:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B88E0606A31A 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=k/9y+p4A Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-8a4c72951b8so7282846b3a.3 for ; Tue, 01 Dec 2026 01:02:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796115744; x=1796720544; 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=sL37OI+fW7/naMTi+7AppvVUyo6nvx9cHdphRMAiohQ=; b=k/9y+p4Am2XNh4NnGJVfT7/uFubpBSJDe+IBEf3MPTSYBFzFa+X4MG92TOKOhdU2Yo s06AqHxxr8fdWau9mqcCQPOMCbt+6XsDQULIwVqkqV9Iyx1IFF4YJYhf1LMj8OKoQnW4 Hvg5Zj6DDAVMyWOZEkaMU8h7TYP9dSPrjkqDTIvSbUgvc5tyKX1rsbI2ag/DQrmNAE2Q hz066ubKxmC60QPKGlHQvnEXLTczHpjWWl0UqBAv6paoiXUNk7UkNzlckhJ90GYXAL1G w8VBmKvtw8KwublcTQQl2KHK6UEfvlBMGqQLLQbMjoot44BsZoZ0vGkuDOu6aEWXXO8q cPmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796115744; x=1796720544; 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=sL37OI+fW7/naMTi+7AppvVUyo6nvx9cHdphRMAiohQ=; b=mIHVzaVAFEbLR/lx869Lqp5w53bq9jFYHq1pWrsV4KQEXc1uJgu0OXDMu21iFSPm/k GRXmyZo0cVhks6/yyeueTA9hTAespIjVVXQgp2aalHJyRhM8DRv00spQnq/brD2NbONY oihzaXOnp4hs9MmNJvS1i9U7K1yezHer4J167irn/dn1FpPgbGtR+3q4uCtu5N0uhWVb +IP2MikEFvdhH5zu+tX2Ooe5lhuTiKCuIeZu14r3QKkJGFSzSnMJRwJ+hcEACHcWeEgb z2JEGV3H97+v+xAZ/cekUc0humQdEegIMTJtxpMa8eIqYHRzIPJw9cV8d5kCx7c6Q5YL Wo2A== X-Forwarded-Encrypted: i=1; AL+hErHIPPlqpAVhAz/1loDTIpBKDkAbHrgA0YpV0KrAfrqzmdheEE1WeHcNueLbBVK96l+N+A1KeXo=@vger.kernel.org X-Gm-Message-State: APuU4Z+DmiY201rNgs9iMlaqK5GS8rWtcp73YDhe4/JVhaJ5fJyyko5y 7bvtJGwi4iO4xzuptFbTf/OT6cS2lxuy+YewOahdHBJrmHeiDakzi6Iv X-Gm-Gg: AZFdTZc7GS/ODO8Z67H8rz5xWorWXFPlvEBfDJ02pWVobKBnpVjB/JfehzWcW0iqVS7 yDV8OALXiz0PKmescYQK4xjmwGCLyKssv7y4G/fdjIeVZFFCV5tQkjSSHm4kaCGd4oOYW5iUDYK sG9KqvZ30qcpRrp9Dc5K+XntHGoZILMh3qOB9Dh7YrH6bSgVd1wkO4fGWK/mnbmK/+/ayjBD2at 7r3CWo1SCGgBHZemYr3gf2g10/tb0L1jyqHp2L/IIFwxCQvwJwKoAftOgA8zhk3LRgs9rGEYk/V nCijT7fNZAQQjXuywdb2W//0zujNx2yD8CwHkreYWcFlt49DP3fYFxeFSY/bqQc+hu44XTcrZS3 Vfq8DCIo2KzEtu+gcly87U5ze731JfmPHnNfeQWlKCD6CSTy48GPdWs/8P3Er6DwXMc/zQ7+qtI cYOBufi1bZDMZIkTOn0sPxnsPnKtg7pFXeO/XRIIbmI4c0XwAz8YSZFxeqDCpYcU8TtgvqAjq6a jwEC4cEmc8IKwnTIzFw+HfvFlNhlUT7V9+nPp5H10DVqlyrqerZsd3FY8mPW+CBRlNCp4sAVfhN HWi1P6tiTYjincgjLSnELhswGBn007RSdPrueeK8aiCaPAZsbIkJ X-Received: by 2002:a05:6a00:414e:b0:8bd:281a:5cb0 with SMTP id d2e1a72fcca58-8c8796a7bb0mr34098830b3a.6.1796115743551; Tue, 01 Dec 2026 01:02:23 -0800 (PST) Received: from [127.0.0.1] ([43.132.141.20]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c87285c05fsm19556360b3a.17.2026.12.01.01.02.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 01:02:23 -0800 (PST) From: zhuorao yang To: Pablo Neira Ayuso , Florian Westphal , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn Cc: netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org Subject: [PATCH net] netfilter: conntrack: serialize helper extension allocation Date: Tue, 1 Dec 2026 16:58:14 +0800 Message-ID: <20261201085814.82573-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 Two CPUs can add the helper extension to the same unconfirmed conntrack when shared skbs are evaluated concurrently. nf_ct_ext_add() then calls krealloc() on the same ct->ext from both CPUs. If the first call moves the extension allocation, the second call can double-free the old one. Serialize nf_ct_helper_ext_add() with the conntrack lock. The lock also covers publishing IPS_HELPER_BIT and initializing the expectation list, so a concurrent caller observes a fully initialized helper extension. 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 public message. AI assistance: DeepSeek identified the issue and drafted the patch. The submitter reviewed the code and certified the Developer Certificate of Origin. net/netfilter/nf_conntrack_helper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c index c30ae3f203be..4d2dd88e74f3 100644 --- a/net/netfilter/nf_conntrack_helper.c +++ b/net/netfilter/nf_conntrack_helper.c @@ -184,11 +184,13 @@ nf_ct_helper_ext_add(struct nf_conn *ct, gfp_t gfp) { struct nf_conn_help *help; + spin_lock_bh(&ct->lock); help = nf_ct_ext_add(ct, NF_CT_EXT_HELPER, gfp); if (help) { __set_bit(IPS_HELPER_BIT, &ct->status); INIT_HLIST_HEAD(&help->expectations); } + spin_unlock_bh(&ct->lock); return help; } EXPORT_SYMBOL_GPL(nf_ct_helper_ext_add); -- 2.56.0