Netdev List
 help / color / mirror / Atom feed
* [PATCH net] netfilter: conntrack: serialize helper extension allocation
@ 2026-12-01  8:58 zhuorao yang
  2026-12-01  9:21 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: zhuorao yang @ 2026-12-01  8:58 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Florian Westphal, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn
  Cc: netfilter-devel, coreteam, netdev

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 <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 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-01  9:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  8:58 [PATCH net] netfilter: conntrack: serialize helper extension allocation zhuorao yang
2026-12-01  9:21 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox