* [PATCH v3] netfilter: nft_ct: reject shared conntrack extension updates
@ 2026-12-04 7:19 zhuorao yang
2026-12-04 7:32 ` netdev-bot+sinfo
0 siblings, 1 reply; 5+ messages in thread
From: zhuorao yang @ 2026-12-04 7:19 UTC (permalink / raw)
To: pablo, fw, davem, edumazet, kuba, pabeni, willemb
Cc: netfilter-devel, coreteam, netdev
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
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v3] netfilter: nft_ct: reject shared conntrack extension updates
2026-12-04 7:19 [PATCH v3] netfilter: nft_ct: reject shared conntrack extension updates zhuorao yang
@ 2026-12-04 7:32 ` netdev-bot+sinfo
2026-12-04 7:33 ` [PATCH v4] " zhuorao yang
0 siblings, 1 reply; 5+ messages in thread
From: netdev-bot+sinfo @ 2026-12-04 7:32 UTC (permalink / raw)
To: zhuorao yang
Cc: pablo, fw, davem, edumazet, kuba, pabeni, willemb,
netfilter-devel, coreteam, netdev
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4] netfilter: nft_ct: reject shared conntrack extension updates
2026-12-04 7:32 ` netdev-bot+sinfo
@ 2026-12-04 7:33 ` zhuorao yang
2026-12-04 7:36 ` netdev-bot+sinfo
2026-12-04 11:12 ` Florian Westphal
0 siblings, 2 replies; 5+ messages in thread
From: zhuorao yang @ 2026-12-04 7:33 UTC (permalink / raw)
To: pablo, fw, davem, edumazet, kuba, pabeni, willemb
Cc: netfilter-devel, coreteam, netdev
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
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v4] netfilter: nft_ct: reject shared conntrack extension updates
2026-12-04 7:33 ` [PATCH v4] " zhuorao yang
@ 2026-12-04 7:36 ` netdev-bot+sinfo
2026-12-04 11:12 ` Florian Westphal
1 sibling, 0 replies; 5+ messages in thread
From: netdev-bot+sinfo @ 2026-12-04 7:36 UTC (permalink / raw)
To: zhuorao yang
Cc: pablo, fw, davem, edumazet, kuba, pabeni, willemb,
netfilter-devel, coreteam, netdev
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] netfilter: nft_ct: reject shared conntrack extension updates
2026-12-04 7:33 ` [PATCH v4] " zhuorao yang
2026-12-04 7:36 ` netdev-bot+sinfo
@ 2026-12-04 11:12 ` Florian Westphal
1 sibling, 0 replies; 5+ messages in thread
From: Florian Westphal @ 2026-12-04 11:12 UTC (permalink / raw)
To: zhuorao yang
Cc: pablo, davem, edumazet, kuba, pabeni, willemb, netfilter-devel,
coreteam, netdev
zhuorao yang <alex000young@gmail.com> wrote:
> 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.
Nak. Playing whack-a-mole with stunts like this is getting us nowhere.
There are dozen of similar bugs like this all over conntrack.
It'll take time to rewrite the core assumptions cleanly. Changes in
dozen different places is not the way to go.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-12-04 11:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 7:19 [PATCH v3] netfilter: nft_ct: reject shared conntrack extension updates zhuorao yang
2026-12-04 7:32 ` netdev-bot+sinfo
2026-12-04 7:33 ` [PATCH v4] " zhuorao yang
2026-12-04 7:36 ` netdev-bot+sinfo
2026-12-04 11:12 ` Florian Westphal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox