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 05/15] netfilter: conntrack: replace open-coded helper invocation
Date: Tue, 24 Nov 2026 14:39:33 +0000 [thread overview]
Message-ID: <179553117362.3135.14148690589375438131@kernel.org> (raw)
In-Reply-To: <20261123135726.3940688-6-pablo@netfilter.org>
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · 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).
- [Medium] This patch changes the OVS/tc helper path in nf_ct_helper()
(net/netfilter/nf_conntrack_ovs.c:30) so that it calls…
- [Medium] netfilter: conntrack: nf_ct_helper() does not verify
nf_ct_l3num(ct) == proto
- [Low] The comment `/* rcu_read_lock()ed by nf_hook */` at
net/netfilter/nf_conntrack_proto.c:211 in nf_ct_call_helper() is now…
--
netfilter: conntrack: replace open-coded helper invocation
The commit replaces the open-coded helper invocation in nf_ct_helper(),
which the OVS datapath and tc act_ct use. It now calls
nf_ct_call_helper(), which nf_confirm() also uses. The commit message
says there are no functional changes, apart from extra checks that make
sure the helper can process the packet.
> diff --git a/net/netfilter/nf_conntrack_ovs.c b/net/netfilter/nf_conntrack_ovs.c
> index fe525b324af41..2a80eaf05186b 100644
> --- a/net/netfilter/nf_conntrack_ovs.c
> +++ b/net/netfilter/nf_conntrack_ovs.c
[ ... ]
> @@ -35,50 +27,7 @@ int nf_ct_helper(struct sk_buff *skb, struct nf_conn *ct,
> helper->nfproto != proto)
> return NF_ACCEPT;
>
[ ... ]
> - default:
> - WARN_ONCE(1, "helper invoked on non-IP family!");
> - return NF_DROP;
> - }
> -
> - if (helper->l4proto != proto)
> - return NF_ACCEPT;
> -
> - helper_cb = rcu_dereference(helper->help);
> - if (!helper_cb)
> - return NF_ACCEPT;
> -
> - err = helper_cb(skb, protoff, ct, ctinfo);
> - if (err != NF_ACCEPT)
> - return err;
> -
> - /* Adjust seqs after helper. This is needed due to some helpers (e.g.,
> - * FTP with NAT) adusting the TCP payload size when mangling IP
> - * addresses and/or port numbers in the text-based control connection.
> - */
> - if (test_bit(IPS_SEQ_ADJUST_BIT, &ct->status) &&
> - !nf_ct_seq_adjust(skb, ct, ctinfo, protoff))
> - return NF_DROP;
> - return NF_ACCEPT;
> + return nf_ct_call_helper(skb, ct, ctinfo);
[Severity: Medium]
Can nf_ct_helper() now pick the helper by one family and parse the
packet by another?
The check left in nf_ct_helper() compares helper->nfproto against the
proto passed in by the caller. nf_ct_call_helper() then calls
nf_confirm_get_protoff(), and that function switches on
nf_ct_l3num(ct) instead:
switch (nf_ct_l3num(ct)) {
case NFPROTO_IPV4:
...
protoff = skb_network_offset(skb) + ip_hdrlen(skb);
*pnum = ip_hdr(skb)->protocol;
break;
case NFPROTO_IPV6:
*pnum = ipv6_hdr(skb)->nexthdr;
...
The removed code also switched on proto when it parsed the headers. So
the helper family check and the protoff and l4proto lookup always used
the same family.
Nothing in nf_ct_helper() checks that nf_ct_l3num(ct) == proto, and
the callers do not seem to guarantee it. In tcf_ct_act(),
tcf_ct_skb_nfct_cached() treats an existing skb->_nfct as cached when
only the net and the zone match:
if (!net_eq(net, read_pnet(&ct->ct_net)))
goto drop_ct;
if (nf_ct_zone(ct)->id != p->zone)
goto drop_ct;
For an unconfirmed ct with commit set, tcf_ct_act() then calls
nf_ct_helper(skb, ct, ctinfo, family) and skips nf_conntrack_in().
skb_nfct_cached() in net/openvswitch/conntrack.c looks similar.
Consider a tc chain with these steps, all in the same zone:
1. A ct action without commit tracks an IPv6 packet.
2. skbedit, pedit or bpf changes skb->protocol to ETH_P_IP.
3. A ct action with commit and an IPv4-only helper runs.
nf_ct_helper() accepts the helper, because helper->nfproto is
NFPROTO_IPV4. nf_confirm_get_protoff() parses the packet as IPv6. An
IPv4 helper such as snmp_trap_helper() finds the UDP header from
ip_hdr(skb)->ihl, not from protoff, so it would run on an IPv6 header.
The reverse case is also possible: act_ct trimmed and classified the
packet as IPv6, but nf_confirm_get_protoff() parses it as IPv4.
Setting this up needs CAP_NET_ADMIN. Still, it changes which bytes the
helper is pointed at, and the commit message only says it adds checks.
The old code also ran the helper against a ct of the other family in
this case, but its header parsing at least matched the family that was
used to pick the helper.
The later patch "harden helper invocation with tuple revalidation"
adds nf_ct_get_tuplepr() to nf_confirm_get_protoff(). It also keys off
nf_ct_l3num(ct), so it does not seem to close this gap.
Should nf_ct_helper() return early when nf_ct_l3num(ct) != proto? Or
should the helper->nfproto check compare against nf_ct_l3num(ct)?
Another option is for the cached checks in act_ct and OVS to reject a
ct whose l3num does not match the current family.
[Severity: Medium]
Does this change when sequence adjustment runs for tc act_ct on
loopback?
In net/netfilter/nf_conntrack_proto.c, nf_ct_call_helper() does this:
seqadj_needed = test_bit(IPS_SEQ_ADJUST_BIT, &ct->status) && !nf_is_loopback_packet(skb);
...
if (seqadj_needed &&
!nf_ct_seq_adjust(skb, ct, ctinfo, protoff))
return NF_DROP;
The removed code called nf_ct_seq_adjust() whenever IPS_SEQ_ADJUST_BIT
was set after a successful helper call. It never checked the device.
nf_is_loopback_packet() is:
return skb->dev && skb->skb_iif && skb->dev->flags & IFF_LOOPBACK;
When tcf_ct_act() runs from a tc ingress filter on lo, this is always
true. __netif_receive_skb_core() sets skb->skb_iif before
sch_handle_ingress() runs:
skb->skb_iif = skb->dev->ifindex;
Consider a pure act_ct setup on lo ingress with commit, nat and a helper
that rewrites the payload, such as ftp. act_ct registers no netfilter
hooks, so nf_confirm() never adjusts these packets. Before this patch,
nf_ct_helper() was the only place that did.
After nf_nat_mangle_tcp_packet() changes the payload length and sets
IPS_SEQ_ADJUST_BIT, will seq/ack go uncorrected on later packets? That
would leave the TCP control connection out of sync.
OVS does not seem able to reach this, because ovs_netdev_link() rejects
IFF_LOOPBACK vports. In a mixed setup where netfilter conntrack already
adjusted the packet in POSTROUTING, skipping the adjustment on lo
ingress does avoid adjusting twice.
The commit message says:
No functional changes intended, except the additional checks to
ensure the helper can process the given packet.
The loopback exemption does not seem to fit that description.
Two smaller behaviour changes also seem to be undisclosed. First, a
NULL helper->help, which happens briefly while a helper is being
unregistered, used to return NF_ACCEPT without any seq adjustment. It
now falls through to nf_ct_seq_adjust().
Second, a non-IP family used to hit WARN_ONCE() and return NF_DROP. It
now returns NF_ACCEPT after DEBUG_NET_WARN_ONCE(). That path is
probably unreachable, because the switch is now on nf_ct_l3num(ct).
Should nf_ct_helper() keep the unconditional seq adjustment for the
act_ct path? Or should the commit message describe these changes? The
behaviour looks the same at the end of the series.
[Severity: Low]
This isn't a bug, but the comment in nf_ct_call_helper() looks stale
now that nf_ct_helper() calls it:
/* rcu_read_lock()ed by nf_hook */
helper = rcu_dereference(help->helper);
Before this patch, nf_confirm() was the only caller, and it runs inside
nf_hook_slow(). Through nf_ct_helper(), this code is now also reached
from the OVS datapath in net/openvswitch/conntrack.c and from
tcf_ct_act() in net/sched/act_ct.c.
Those paths get their RCU read-side section from somewhere else: the
netdev rx handler, ovs_packet_cmd_execute(), or tc classify. The
rcu_dereference() calls are still protected in practice, so only the
comment is wrong.
Could the comment be updated to cover the new callers? It is unchanged
at the end of the series.
> }
> EXPORT_SYMBOL_GPL(nf_ct_helper);
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123135726.3940688-2-pablo%40netfilter.org
next prev parent 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
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 [this message]
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 05/15] netfilter: conntrack: replace open-coded helper invocation 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=179553117362.3135.14148690589375438131@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