Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org, davem@davemloft.net,
	netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com,
	edumazet@kernel.org, horms@kernel.org, fw@strlen.de, ja@ssi.bg
Subject: Re: [PATCH net-next 04/15] netfilter: conntrack: verify L4 protocol before calling helper
Date: Tue, 24 Nov 2026 14:39:32 +0000	[thread overview]
Message-ID: <179553117201.3135.14194838592566427007@kernel.org> (raw)
In-Reply-To: <20261123135726.3940688-5-pablo@netfilter.org>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 2 · Medium: 0 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] This patch breaks the H.245 helper on the normal netfilter path,
  which breaks H.323 media tracking and NAT.
- [High] nft_ct_expect_helper_alloc() now sets the internal helper's
  l4proto to `priv->l4proto` (NFTA_CT_EXPECT_L4PROTO).
- [Low] The commit message does not fully describe the behaviour change.

--

netfilter: conntrack: verify L4 protocol before calling helper

This commit makes nf_ct_call_helper() skip the assigned conntrack helper
when the packet's L4 protocol does not match helper->l4proto. It also
skips IPv4 fragments and packets with no L4 payload. It sets l4proto on
the internal helper that nft_ct expectation objects allocate.

> diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
> index 32f900c155de8..18125aa29e0d0 100644
> --- a/net/netfilter/nf_conntrack_proto.c
> +++ b/net/netfilter/nf_conntrack_proto.c
> @@ -134,21 +134,23 @@ static bool in_vrf_postrouting(const struct nf_hook_state *state)

[ ... ]

>  	case NFPROTO_IPV6:
> -		pnum = ipv6_hdr(skb)->nexthdr;
> -		start = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &pnum, &frag_off);
> -		if (start < 0 || (frag_off & htons(~0x7)) != 0)
> +		*pnum = ipv6_hdr(skb)->nexthdr;
> +		start = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), pnum, &frag_off);
> +		if (start < 0 || frag_off)
>  			return false;

[Severity: Low]
This isn't a bug, but the commit message only mentions IPv4:

  Also change ipv4 to explicitly skip frasgments, this shouldn't happen
  for normal netfilter-only code path, ...

The IPv6 check in nf_confirm_get_protoff() changes too. ipv6_skip_exthdr()
returns the raw frag_off field, including the M bit and the reserved
bits. So the new check also rejects first fragments (offset 0, M=1) and
atomic fragments with reserved bits set. Before, both of those still
went through the helper and seqadj.

The new check also no longer matches the unchanged IPv6 check in
nf_ct_helper() in nf_conntrack_ovs.c.

Could the commit message mention the IPv6 change as well?

The commit message also says:

  or when conntrack got attached via TC/act_ct, then was later munged via
  act_pipe to alter the ip protocol.

There doesn't seem to be an act_pipe tc action. Should this say
pedit/bpf, like the new comment above nf_ct_call_helper()? Also, there's
a typo (frasgments).

[ ... ]

> @@ -204,6 +210,9 @@ int nf_ct_call_helper(struct sk_buff *skb, struct nf_conn *ct,
>  		/* rcu_read_lock()ed by nf_hook */
>  		helper = rcu_dereference(help->helper);
>  		if (helper) {
> +			if (helper->l4proto != pnum)
> +				return NF_ACCEPT;
> +

[Severity: High]
Does this guard break the H.245 helper on the normal netfilter path?

h323_helper_init() in nf_conntrack_h323_main.c registers H.245 as a UDP
helper:

	nf_ct_helper_init(&nf_conntrack_helper_h245, AF_UNSPEC, IPPROTO_UDP,
			  "H.245",
			  &h245_exp_policy, 0, h245_help, NULL, THIS_MODULE);

However, expect_h245() creates a TCP expectation and assigns that helper
to the TCP child conntrack:

	nf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),
			  &ct->tuplehash[!dir].tuple.src.u3,
			  &ct->tuplehash[!dir].tuple.dst.u3,
			  IPPROTO_TCP, NULL, &port);
	rcu_assign_pointer(exp->assign_helper, nf_conntrack_helper_h245_ptr);

h245_help() also parses TCP: get_tpkt_data() reads a struct tcphdr at
protoff.

With this patch, every H.245 packet takes this path:

q931_help()->expect_h245()   (TCP expectation, H.245 helper)
nf_confirm()->nf_ct_call_helper()
    nf_confirm_get_protoff() sets pnum = IPPROTO_TCP
    helper->l4proto (IPPROTO_UDP) != pnum -> return NF_ACCEPT

As a result h245_help() never runs. No RTP/RTCP/T.120 expectations are
created and the H.245 NAT payload rewrite is skipped. Wouldn't H.323
calls through an iptables/nftables conntrack/NAT box lose their media?

Before this patch nf_confirm() didn't check the protocol. Only the
nf_ct_helper() path used by OVS/act_ct had this check. This still seems
to be the case at the end of the series.

Should the H.245 helper be registered with IPPROTO_TCP as part of this
change? This matters more because the Fixes: tag makes the patch a
stable candidate on its own.

>  			helper_cb = rcu_dereference(helper->help);
>  			if (helper_cb) {
>  				ret = helper_cb(skb, protoff,
> diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c
> index 5a8db55920364..58846bc405b7e 100644
> --- a/net/netfilter/nft_ct.c
> +++ b/net/netfilter/nft_ct.c
> @@ -1307,6 +1307,7 @@ static int nft_ct_expect_helper_alloc(struct nft_ct_expect_obj *priv)
>  		 "nft_ct_expect");
>  	ct_expect_helper->me = THIS_MODULE;
>  	ct_expect_helper->expect_policy[NF_CT_EXPECT_CLASS_DEFAULT].max_expected = priv->size;
> +	ct_expect_helper->l4proto = priv->l4proto;

[Severity: High]
Is priv->l4proto the right value to store here?

In the expectation object, l4proto is the protocol of the expected child
connection. ct_expect_help() passes it as the protocol of the
expectation tuple:

	nf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, l3num,
			  &ct->tuplehash[!dir].tuple.src.u3,
			  &ct->tuplehash[!dir].tuple.dst.u3,
			  expect_data->obj.l4proto, NULL, &expect_data->obj.dport);

The new guard in nf_ct_call_helper() compares helper->l4proto with the
L4 protocol of the master connection that the helper is attached to.

nft_ct_expect_obj_eval() attaches the helper to any unconfirmed
conntrack. Unlike nft_ct_helper_obj_eval(), it doesn't check
nf_ct_protonum(ct) against priv->l4proto:

	if (help && refcount_inc_not_zero(&priv->helper->ct_refcnt))
		rcu_assign_pointer(help->helper, priv->helper);

The nft documentation shows a TCP control connection with a UDP
expectation:

  ct state new tcp dport 8888 ct expectation set "expect"

Here the expectation object uses "protocol udp". So pnum is IPPROTO_TCP
and helper->l4proto is IPPROTO_UDP. ct_expect_help() never runs and no
expectation is created. Nothing reports an error, either at rule load
or at runtime.

Before this patch, helper->l4proto was 0 from kzalloc and nf_confirm()
didn't check it, so expectations with a different protocol than the
master worked. The code is still unchanged at the end of the series.

Could the check use the master connection's protocol for this helper
instead? Another option is to reject the mismatch in
nft_ct_expect_obj_eval().

A smaller point: the l4proto field comment in struct
nf_conntrack_helper says IPPROTO_UDP/TCP, but this assignment can now
store DCCP or SCTP.

>  	rcu_assign_pointer(ct_expect_helper->help, ct_expect_help);
>  	refcount_set(&ct_expect_helper->ct_refcnt, 1);

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123135726.3940688-2-pablo%40netfilter.org

  reply	other threads:[~2026-11-24 14:39 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 13:57 [PATCH net-next,v2 00/15] Netfilter updates for net-next Pablo Neira Ayuso
2026-11-23 13:57 ` [PATCH net-next 01/15] netfilter: conntrack: prevent nf_conntrack_buckets race condition Pablo Neira Ayuso
2026-11-23 14:02   ` netdev-bot+sinfo
2026-11-23 14:17     ` Pablo Neira Ayuso
2026-11-23 13:57 ` [PATCH net-next 02/15] netfilter: conntrack: validate skb->_nfct and packet headers Pablo Neira Ayuso
2026-11-24 14:39   ` netdev-bot+sashiko
2026-11-23 13:57 ` [PATCH net-next 03/15] netfilter: conntrack: refactor helper call logic in nf_confirm() Pablo Neira Ayuso
2026-11-24 14:39   ` netdev-bot+sashiko
2026-11-23 13:57 ` [PATCH net-next 04/15] netfilter: conntrack: verify L4 protocol before calling helper Pablo Neira Ayuso
2026-11-24 14:39   ` netdev-bot+sashiko [this message]
2026-11-23 13:57 ` [PATCH net-next 05/15] netfilter: conntrack: replace open-coded helper invocation Pablo Neira Ayuso
2026-11-24 14:39   ` netdev-bot+sashiko
2026-11-23 13:57 ` [PATCH net-next 06/15] netfilter: conntrack: harden helper invocation with tuple revalidation Pablo Neira Ayuso
2026-11-24 14:39   ` netdev-bot+sashiko
2026-11-23 13:57 ` [PATCH net-next 07/15] netfilter: nft_ct: validate timeout object protocol Pablo Neira Ayuso
2026-11-24 14:39   ` netdev-bot+sashiko
2026-11-23 13:57 ` [PATCH net-next 08/15] netfilter: nft_synproxy: only handle pure SYN and ACK packets Pablo Neira Ayuso
2026-11-23 13:57 ` [PATCH net-next 09/15] netfilter: nft_ct: validate hook and priority for ct zone set Pablo Neira Ayuso
2026-11-24 14:39   ` netdev-bot+sashiko
2026-11-23 13:57 ` [PATCH net-next 10/15] rhashtable: Add rhashtable_flush_and_free helper Pablo Neira Ayuso
2026-11-24 14:39   ` netdev-bot+sashiko
2026-11-23 13:57 ` [PATCH net-next 11/15] netfilter: ipset: add rhashtable boilerplate stubs Pablo Neira Ayuso
2026-11-24 14:39   ` netdev-bot+sashiko
2026-11-23 13:57 ` [PATCH net-next 12/15] netfilter: ipset: replace internal hash table with rhashtable Pablo Neira Ayuso
2026-11-24 14:39   ` netdev-bot+sashiko
2026-11-23 13:57 ` [PATCH net-next 13/15] netfilter: ipset: also report mem size for cidr storage to userspace Pablo Neira Ayuso
2026-11-24 14:39   ` netdev-bot+sashiko
2026-11-23 13:57 ` [PATCH net-next 14/15] netfilter: ipset: re-add IP_SET_HASH_WITH_MULTI support Pablo Neira Ayuso
2026-11-24 14:39   ` netdev-bot+sashiko
2026-11-23 13:57 ` [PATCH net-next 15/15] netfilter: ipset: re-add forceadd support Pablo Neira Ayuso
2026-11-24 14:39   ` netdev-bot+sashiko
2026-11-24 12:27 ` [PATCH net-next,v2 00/15] Netfilter updates for net-next Paolo Abeni
2026-11-24 12:36   ` Florian Westphal
2026-11-24 13:47     ` Paolo Abeni
2026-11-24 13:33   ` Pablo Neira Ayuso
2026-11-24 13:43     ` Paolo Abeni
  -- strict thread matches above, loose matches on Subject: below --
2026-11-23 13:54 [PATCH net-next " Pablo Neira Ayuso
2026-11-23 13:54 ` [PATCH net-next 04/15] netfilter: conntrack: verify L4 protocol before calling helper Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179553117201.3135.14194838592566427007@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=ja@ssi.bg \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox