* [PATCH nf 1/2] netfilter: conntrack: reject helper protocol mismatch
2026-11-27 21:09 [PATCH nf 0/2] netfilter: reject mismatched conntrack template protocols Dickson Wu via B4 Relay
@ 2026-11-27 18:12 ` Dickson Wu via B4 Relay
2026-11-28 22:02 ` Pablo Neira Ayuso
2026-11-27 18:12 ` [PATCH nf 2/2] netfilter: conntrack: reject timeout " Dickson Wu via B4 Relay
1 sibling, 1 reply; 5+ messages in thread
From: Dickson Wu via B4 Relay @ 2026-11-27 18:12 UTC (permalink / raw)
To: netfilter-devel
Cc: Pablo Neira Ayuso, Florian Westphal, Phil Sutter, coreteam,
netdev
From: Dickson Wu <dickson.wu@certik.com>
Conntrack templates can carry helpers selected from rule metadata instead
of the packet protocol. nft_compat does not enforce its compatibility
protocol when evaluating packets, so xt_CT can attach a UDP helper to a
TCP conntrack. act_ct can likewise attach a helper configured for another
protocol.
Helpers parse transport headers according to helper->l4proto. With the
H.323 RAS helper attached to TCP traffic, NAT mangling in
mangle_contents() crashes. Refuse to copy a template helper unless it
matches the new conntrack protocol. This covers all template users in
the common assignment path.
Fixes: 84f3bb9ae9db ("netfilter: xtables: add CT target")
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
---
This was found and the fix prepared with AI coding tools (OpenAI Codex
agents, with review by Claude). I went over the analysis and the patch
before signing off.
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 c30ae3f203..91bd11f01f 100644
--- a/net/netfilter/nf_conntrack_helper.c
+++ b/net/netfilter/nf_conntrack_helper.c
@@ -209,6 +209,8 @@ int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl,
help = nfct_help(tmpl);
if (help)
helper = rcu_dereference(help->helper);
+ if (helper && helper->l4proto != nf_ct_protonum(ct))
+ helper = NULL;
help = nfct_help(ct);
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH nf 2/2] netfilter: conntrack: reject timeout protocol mismatch
2026-11-27 21:09 [PATCH nf 0/2] netfilter: reject mismatched conntrack template protocols Dickson Wu via B4 Relay
2026-11-27 18:12 ` [PATCH nf 1/2] netfilter: conntrack: reject helper protocol mismatch Dickson Wu via B4 Relay
@ 2026-11-27 18:12 ` Dickson Wu via B4 Relay
1 sibling, 0 replies; 5+ messages in thread
From: Dickson Wu via B4 Relay @ 2026-11-27 18:12 UTC (permalink / raw)
To: netfilter-devel
Cc: Pablo Neira Ayuso, Florian Westphal, Phil Sutter, coreteam,
netdev
From: Dickson Wu <dickson.wu@certik.com>
A conntrack template can carry a timeout policy selected from rule
metadata instead of the packet protocol. nft_compat does not enforce its
compatibility protocol when evaluating packets, so an ICMP or UDP policy
can be copied to a TCP conntrack.
Timeout data is laid out for one protocol tracker, so an ICMP policy on
a TCP conntrack makes nf_conntrack_tcp_packet() read past the end of the
timeout object. Copy a template timeout only when its protocol matches
the new conntrack.
Fixes: 24de58f46516 ("netfilter: xt_CT: allow to attach timeout policy + glue code")
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
---
This was found and the fix prepared with AI coding tools (OpenAI Codex
agents, with review by Claude). I went over the analysis and the patch
before signing off.
net/netfilter/nf_conntrack_core.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 931b76aacd..eaae27bf09 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -1782,9 +1782,13 @@ init_conntrack(struct net *net, struct nf_conn *tmpl,
timeout_ext = tmpl ? nf_ct_timeout_find(tmpl) : NULL;
- if (timeout_ext)
- nf_ct_timeout_ext_add(ct, rcu_dereference(timeout_ext->timeout),
- GFP_ATOMIC);
+ if (timeout_ext) {
+ struct nf_ct_timeout *timeout;
+
+ timeout = rcu_dereference(timeout_ext->timeout);
+ if (timeout && timeout->l4proto->l4proto == nf_ct_protonum(ct))
+ nf_ct_timeout_ext_add(ct, timeout, GFP_ATOMIC);
+ }
nf_ct_acct_ext_add(ct, GFP_ATOMIC);
nf_ct_tstamp_ext_add(ct, GFP_ATOMIC);
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH nf 0/2] netfilter: reject mismatched conntrack template protocols
@ 2026-11-27 21:09 Dickson Wu via B4 Relay
2026-11-27 18:12 ` [PATCH nf 1/2] netfilter: conntrack: reject helper protocol mismatch Dickson Wu via B4 Relay
2026-11-27 18:12 ` [PATCH nf 2/2] netfilter: conntrack: reject timeout " Dickson Wu via B4 Relay
0 siblings, 2 replies; 5+ messages in thread
From: Dickson Wu via B4 Relay @ 2026-11-27 21:09 UTC (permalink / raw)
To: netfilter-devel
Cc: Pablo Neira Ayuso, Florian Westphal, Phil Sutter, coreteam,
netdev
xt_CT under nft_compat can attach a helper or timeout policy selected from
NFTA_RULE_COMPAT_PROTO to packets of another protocol. The helper mismatch
also affects act_ct through the common template assignment path.
Reject mismatched helpers and timeout policies when a conntrack copies its
template state.
Tested under UML with KASAN, with the trigger running as uid 1000 in new
user and network namespaces (namespace-local CAP_NET_ADMIN only):
- nft_compat xt_CT with the H.323 RAS helper on TCP: stock panics in
mangle_contents(); patched completes; reverted panics again.
- act_ct with the RAS helper on TCP: stock panics in ras_help() from the
receive softirq; patched completes; reverted panics again.
- xt_CT with an ICMP timeout policy on TCP: stock gives a KASAN
slab-out-of-bounds read in nf_conntrack_tcp_packet(); patched keeps the
default TCP timeout; reverted reads out of bounds again.
- Matching-protocol controls still work: UDP H.323, TCP FTP, and ICMP
and UDP timeout policies.
W=1 builds are clean. The rule-load checks in xt_CT and nft_ct already
require an exact protocol match, so valid configurations are unaffected.
The gap is nft_compat not enforcing its compat protocol per packet, and
act_ct.
A reproducer is available if it helps.
This was found and the fix prepared with AI coding tools (OpenAI Codex
agents, with review by Claude). I went over the analysis and the patch
before signing off.
---
Dickson Wu (2):
netfilter: conntrack: reject helper protocol mismatch
netfilter: conntrack: reject timeout protocol mismatch
net/netfilter/nf_conntrack_core.c | 10 +++++++---
net/netfilter/nf_conntrack_helper.c | 2 ++
2 files changed, 9 insertions(+), 3 deletions(-)
---
base-commit: 734bef548a96e8774d6eef5dfa2026c6edc4e80b
change-id: 20261127-nf-ctproto2-0508bd9bfeb7
Best regards,
--
Dickson Wu <dickson.wu@certik.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH nf 1/2] netfilter: conntrack: reject helper protocol mismatch
2026-11-27 18:12 ` [PATCH nf 1/2] netfilter: conntrack: reject helper protocol mismatch Dickson Wu via B4 Relay
@ 2026-11-28 22:02 ` Pablo Neira Ayuso
2026-11-28 22:34 ` Dickson Wu
0 siblings, 1 reply; 5+ messages in thread
From: Pablo Neira Ayuso @ 2026-11-28 22:02 UTC (permalink / raw)
To: dickson.wu
Cc: netfilter-devel, Florian Westphal, Phil Sutter, coreteam, netdev
On Fri, Nov 27, 2026 at 06:12:10PM +0000, Dickson Wu via B4 Relay wrote:
> From: Dickson Wu <dickson.wu@certik.com>
>
> Conntrack templates can carry helpers selected from rule metadata instead
> of the packet protocol. nft_compat does not enforce its compatibility
> protocol when evaluating packets, so xt_CT can attach a UDP helper to a
> TCP conntrack. act_ct can likewise attach a helper configured for another
> protocol.
>
> Helpers parse transport headers according to helper->l4proto. With the
> H.323 RAS helper attached to TCP traffic, NAT mangling in
> mangle_contents() crashes. Refuse to copy a template helper unless it
> matches the new conntrack protocol. This covers all template users in
> the common assignment path.
>
> Fixes: 84f3bb9ae9db ("netfilter: xtables: add CT target")
> Signed-off-by: Dickson Wu <dickson.wu@certik.com>
> ---
> This was found and the fix prepared with AI coding tools (OpenAI Codex
> agents, with review by Claude). I went over the analysis and the patch
> before signing off.
There is ongoing work in the mailing list.
Your LLM is just reporting you something for which there are already
patches on the mailing list?
Could you please check the mailing list before posting duplicate
patches?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH nf 1/2] netfilter: conntrack: reject helper protocol mismatch
2026-11-28 22:02 ` Pablo Neira Ayuso
@ 2026-11-28 22:34 ` Dickson Wu
0 siblings, 0 replies; 5+ messages in thread
From: Dickson Wu @ 2026-11-28 22:34 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: netfilter-devel, Florian Westphal, Phil Sutter, coreteam, netdev
On Sat, Nov 28, 2026 at 10:02:42PM +0000, Pablo Neira Ayuso wrote:
> There is ongoing work in the mailing list.
>
> Your LLM is just reporting you something for which there are already
> patches on the mailing list?
>
> Could you please check the mailing list before posting duplicate
> patches?
Hi Pablo,
You're right, sorry about that. Your 04/15 ("netfilter: conntrack:
verify L4 protocol before calling helper") and 07/15 ("netfilter:
nft_ct: validate timeout object protocol") from 11-23 already cover
both of these, and I missed them. My duplicate check only looked for
matching subjects and code, not the same bug fixed a different way.
That's on me, and I'll search the list by topic before posting anything
else to netfilter.
Please drop this series.
We ran your 07/15 against our timeout reproducer and it fixes it, so
I'm happy to send a Tested-by on the respin if that helps.
Thanks,
Dickson
On Sat, 28 Nov 2026 23:02:42 +0100, Pablo Neira Ayuso
<pablo@netfilter.org> wrote:
> On Fri, Nov 27, 2026 at 06:12:10PM +0000, Dickson Wu via B4 Relay wrote:
> > From: Dickson Wu <dickson.wu@certik.com>
> >
> > Conntrack templates can carry helpers selected from rule metadata instead
> > of the packet protocol. nft_compat does not enforce its compatibility
> > protocol when evaluating packets, so xt_CT can attach a UDP helper to a
> > TCP conntrack. act_ct can likewise attach a helper configured for another
> > protocol.
> >
> > Helpers parse transport headers according to helper->l4proto. With the
> > H.323 RAS helper attached to TCP traffic, NAT mangling in
> > mangle_contents() crashes. Refuse to copy a template helper unless it
> > matches the new conntrack protocol. This covers all template users in
> > the common assignment path.
> >
> > Fixes: 84f3bb9ae9db ("netfilter: xtables: add CT target")
> > Signed-off-by: Dickson Wu <dickson.wu@certik.com>
> > ---
> > This was found and the fix prepared with AI coding tools (OpenAI Codex
> > agents, with review by Claude). I went over the analysis and the patch
> > before signing off.
>
> There is ongoing work in the mailing list.
>
> Your LLM is just reporting you something for which there are already
> patches on the mailing list?
>
> Could you please check the mailing list before posting duplicate
> patches?
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-28 22:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 21:09 [PATCH nf 0/2] netfilter: reject mismatched conntrack template protocols Dickson Wu via B4 Relay
2026-11-27 18:12 ` [PATCH nf 1/2] netfilter: conntrack: reject helper protocol mismatch Dickson Wu via B4 Relay
2026-11-28 22:02 ` Pablo Neira Ayuso
2026-11-28 22:34 ` Dickson Wu
2026-11-27 18:12 ` [PATCH nf 2/2] netfilter: conntrack: reject timeout " Dickson Wu via B4 Relay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox