Article View: linux.kernel.netdev
Article #21858Re: [PATCH net-next 05/15] netfilter: conntrack: replace open-coded helper invocation
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 14:39
Date: Tue, 24 Nov 2026 14:39
218 lines
16046 bytes
16046 bytes
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
Technical Details
Message-ID:
<179553117362.3135.14148690589375438131@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370462-linux-kernel-netdev=dewy.ruReferences:
<20261123135726.3940688-6-pablo@netfilter.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370462-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 05/15] netfilter: conntrack: replace open-coded helper invocation Date: Tue, 24 Nov 2026 14:39:33 +0000 Organization: Usenet Network Message-ID: <179553117362.3135.14148690589375438131@kernel.org> References: <20261123135726.3940688-6-pablo@netfilter.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="4159598"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:+RmpgKPUUltTOgWY1ru08kOQUgE= sha256:Z6SRn4faShl1oFB2zh7FB9+OfPNID2rv1/vWMUwDkSg= sha1:CNJgGC3646MsHzLyp83i7dC18yw= sha256:OEBMzDNhPhxWbYtjzN7YGszc5dYUAtrZst/5iwVSGYo= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id BCA06125E1C; Tue, 24 Nov 2026 17:39:57 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CFcW6ONRVe78; Tue, 24 Nov 2026 17:39:53 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-370462-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 852F2125E1D; Tue, 24 Nov 2026 17:39:45 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id EA99134F0A; Tue, 24 Nov 2026 14:39:37 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795531176; b=ZZV5Inv3BlzMdah6OWnbKUutHr6OKIqs3kZ2Ar8Ug3KBCDMuoWlN3tW57jN4nVlcfFfW osJSPKmhRjtrgv/hWwm/5HLsa3qHK61faRGgr7nCA10pt+3DT5J+w7IsM+dWPX2zJBmXl +tHth93SVSrHyK9CO7mbaI3ULG5B5UlWMaop3UArClllpLLA540yDXkLAgw75I2gFOkTk yQNjjjqhCLil9Kzg78gCW1e4biSneDkjYjiheojsusASCMWguAAMCi0MWtcMmiX3jq4o5 MvkfpZaSH1fKaiCAroKyZJ1iusJ3ahuG2hyo94SgWphMjzvfgkTpQCmGazavWHslTUQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795531176; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=TXNbTZIFkURe4DDU63HqIMXwC3wYeijQ0bXyCiJSP3g=; b=4Z71et+6wxYXxeVStaDSi0jCdOVDvYkAn2WjeIUHkeSweO4cbXoxccRWXkCr2Wq52Vrr 1oK+TK8Cpk3CwY1L3FztR8e9MWSEmK8wvCklG8025ZNY72TEv9PCDY/CECP68nimwbrXG R6Gjr+e0tgCu3UC7Nb+f8PvQX1K87Zgz5zB/EqNx87fGsReQ1rkJiMxt2zVFN4oqXNL7Y JWDLurukE2iRWq2d2F8DfmWYgnsE1uXBM/oSIFl8WSHrnihDEH/chkU3ATTdZ3kWAC9tV yH5Hgf0/fsZgXuJ0GMxUKQCNkL42JTyR0E7xx4yQe8ANHGnV/CiY0mBNvJ1j7MRyk6A== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Hc794+bL; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 307E7606A331; Tue, 24 Nov 2026 14:39:36 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Hc794+bL X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795531175; b=vQEsIIQynAqdfck0dlgbPt2MdI7LTWCWS6yZbEJe+WAZfr0UNO1jiqTpFwfv1aIvchMz 3FNJsuyxJ5bZRtwQl6Y2yFUveHz/TVw+H9sKmV+MZ38aBh+TPQGyFSuxAs5a/wTbDxcp2 J6egvM+NgXxvreq2NsHwkf97S0paoOLmuq9/r4O5zJkOqXj8I67rbnxplqQAFYO49gt56 8G677JsktLeTTOB9eyGb8kEBPBLvlb5UUDcvciod6CbQGglsqrwdsFK9cn0jjiJoEGfXO qdxyPbT13H5ZOVbpSvec/fyht6/aySzcG/G1H+1sl1eAnMyEgrpxOUS/ZiCJtD44TCw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795531175; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=TXNbTZIFkURe4DDU63HqIMXwC3wYeijQ0bXyCiJSP3g=; b=gC2a9IySgihd6HYftdH5onrufhXFBg7GDKk3o+PbhsVCWIga1eojN5odIUad/amOWyZx 9yP5BCPmnxwAhGKAgTCwZl20XqVFn4Gt4McWAXYmNbTCvP1WTY4QWG3rBSgWR6L3vePfH fappUHGMWKEBqxFmSEWuiVhc6QIRG86VN8Ect61qRX1oYupzUu87y7QoSqkZi4SkFU8oc K4HtCWH5RhXya9i8Ci81dVL0T+DkyeehNE589esRlArdK+i/+edmVzKKUtQh3fJxisCEM KA6X4vsjKgcrFGYZQM+Gpfeyy6dDmPkElUu61IkOZ0KcY/k18KQSYN+jTCUYwVOwL8Q== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Hc794+bL; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5151F606A326; Tue, 24 Nov 2026 14:39:35 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 168FC1F000D0; Tue, 24 Nov 2026 14:39:34 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795531174; bh=TXNbTZIFkURe4DDU63HqIMXwC3wYeijQ0bXyCiJSP3g=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Hc794+bLZOgu+BAxlGtyBHVphgzUijDgUWfkPcw7XXH0E4Xq1X82tUgPb2+Bcs454 Dm95h5Z2R3y56qYId0qguFpxjGeKd25ydmXyrsMkI6D+JsLsbFvif09ihyZAhvJgog s4XElXLPoSkjjrDs3irMx6OU2z0bfY06Bz2+PNSu1sSzf7ltwpjbGGy3RydRK/SBMF HnNnT5hqsTM7NmP3OCp6IasLxe00Lpj9+0hid1GB4PRpkxeTr5nxkRRKd/rmIIkPVz qWvEZ3S2oHuZK+UET7mzUK3LIvoOmOCYBzIuirOT6zHJveZep2vROTid+5oAQ8jdj3 IeQMxaiMyU0nQ== X-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 X-In-Reply-To: <20261123135726.3940688-6-pablo@netfilter.org> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list