Article View: linux.kernel.netdev
Article #21861Re: [PATCH net-next 03/15] netfilter: conntrack: refactor helper call logic in nf_confirm()
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 14:39
Date: Tue, 24 Nov 2026 14:39
140 lines
12902 bytes
12902 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · 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] The patch makes nf_ct_call_helper()/nf_confirm_get_protoff()
the central place for helper and seqadj invocation and protoff…
- [Low] The new kernel-doc for nf_ct_call_helper() says it "calls the l4
connection tracking helper (e.g. ftp, sip...) if one was assigned to…
--
netfilter: conntrack: refactor helper call logic in nf_confirm()
This splits nf_confirm() into two parts. nf_confirm_get_protoff() computes
the L4 offset for IPv4/IPv6, and nf_ct_call_helper() decides whether to
run the conntrack helper and/or TCP sequence adjustment. The drop counter
is now bumped in nf_confirm() for any NF_DROP verdict, and followup patches
are meant to add stricter checks to the new functions.
> diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
> index 7a40e4e0e33e6..32f900c155de8 100644
> --- a/net/netfilter/nf_conntrack_proto.c
> +++ b/net/netfilter/nf_conntrack_proto.c
[ ... ]
> @@ -169,16 +149,56 @@ unsigned int nf_confirm(void *priv,
[ ... ]
> +/**
> + * nf_ct_call_helper() - Invoke the connection tracking helper for a packet
> + * @skb: The socket buffer containing the packet to be processed.
> + * @ct: The connection tracking entry associated with this packet.
> + * @ctinfo: The current connection track information (state) of the packet.
> + *
> + * This function calls the l4 connection tracking helper (e.g. ftp, sip...) if
> + * one was assigned to the connection.
[Severity: Low]
This isn't a bug, but should this kernel-doc also mention sequence
adjustment? If there is no helper but IPS_SEQ_ADJUST_BIT is set,
nf_ct_call_helper() gets past this check:
if (!help && !seqadj_needed)
return NF_ACCEPT;
It can then mangle the packet or return NF_DROP by itself:
if (seqadj_needed &&
!nf_ct_seq_adjust(skb, ct, ctinfo, protoff))
return NF_DROP;
The new nf_confirm() kernel-doc also lists only helper invocation and
confirmation, and leaves out seqadj. This is still the case at the end of
the series, where nf_ct_helper() has been converted to call this function.
> + *
> + * Return: verdict (NF_ACCEPT, NF_DROP, ...)
> + */
> +int nf_ct_call_helper(struct sk_buff *skb, struct nf_conn *ct,
> + enum ip_conntrack_info ctinfo)
> +{
[ ... ]
> + /* helper->help() do not expect ICMP packets */
> + if (ctinfo == IP_CT_RELATED_REPLY)
> + return NF_ACCEPT;
> +
> + if (!nf_confirm_get_protoff(skb, net, ct, ctinfo, &protoff))
> + return NF_ACCEPT;
[Severity: Medium]
nf_ct_call_helper() and nf_confirm_get_protoff() are now the central place
for helper/seqadj invocation. Should nf_confirm_cthelper() in
net/netfilter/nf_conntrack_core.c go through them as well?
It runs for every accepted nfqueue verdict:
nfqnl_reinject()
ct_hook->update()
nf_conntrack_update()
nf_confirm_cthelper()
nf_ct_seq_adjust()
It still open-codes the old protoff calculation:
net/netfilter/nf_conntrack_core.c:nf_confirm_cthelper() {
...
case NFPROTO_IPV4:
protoff = skb_network_offset(skb) + ip_hdrlen(skb);
break;
...
protoff = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &pnum,
&frag_off);
...
if (test_bit(IPS_SEQ_ADJUST_BIT, &ct->status) &&
!nf_is_loopback_packet(skb)) {
if (!nf_ct_seq_adjust(skb, ct, ctinfo, protoff)) {
...
}
This path has no IP_CT_RELATED_REPLY filter, no IPv4 fragment check, and
no L4 protocol, tuple or TCP doff check. The IPv6 case also lacks the
nhoff that the later hardening adds.
Two followups add those checks: "netfilter: conntrack: verify L4 protocol
before calling helper" and "netfilter: conntrack: harden helper invocation
with tuple revalidation". Both put them only inside
nf_confirm_get_protoff() and nf_ct_call_helper().
"netfilter: conntrack: replace open-coded helper invocation" converts
nf_ct_helper() in nf_conntrack_ovs.c. The nfqueue reinject copy is still
not converted at the end of the series.
Can nf_ct_seq_adjust() then rewrite tcph->seq, ack_seq, check and the SACK
blocks at a non-TCP offset? Take a conntrack that has a userspace cthelper
(NF_CT_HELPER_F_USERSPACE) and IPS_SEQ_ADJUST_BIT set. Two cases look
reachable:
- an ICMP error (IP_CT_RELATED or IP_CT_RELATED_REPLY) related to the
flow that matches a queue rule
- a packet whose L3/L4 headers userspace rewrote through NFQA_PAYLOAD
The writes stay in bounds because nf_ct_seq_adjust() and
nf_ct_sack_adjust() call skb_ensure_writable(). The result would be a
corrupted packet, not corrupted memory.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123135726.3940688-2-pablo%40netfilter.org
Technical Details
Message-ID:
<179553117043.3135.12759318924641866063@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370460-linux-kernel-netdev=dewy.ruReferences:
<20261123135726.3940688-4-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!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370460-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 03/15] netfilter: conntrack: refactor helper call logic in nf_confirm() Date: Tue, 24 Nov 2026 14:39:30 +0000 Organization: Usenet Network Message-ID: <179553117043.3135.12759318924641866063@kernel.org> References: <20261123135726.3940688-4-pablo@netfilter.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="4159816"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:OMsE9639vwjIlXLogiwcyxCDnyg= sha256:f2CY0w9XNtG6X3mG1N7+OroILzfWpbYDsFQm8SOrutA= sha1:dwrf8WUxfFFRUcA50wpHwY0O5Cw= sha256:VbcxMgbPjcylVItM3rOtfO/wMcmLLCDeJ5ZesA0tp0Q= 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 CBDC4125E1E; Tue, 24 Nov 2026 17:40:03 +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 tzMNJyFKTgZb; Tue, 24 Nov 2026 17:40:00 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-370460-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 ABB8F125E1A; Tue, 24 Nov 2026 17:39:50 +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 5E50B354C1; Tue, 24 Nov 2026 14:39:41 +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=1795531177; b=L3zm1OXncRooo+cm14omlj0CHVlZAPz50OL7BbrxtstO9/OoxkpDmMjflkZX2ISvd8OW YAY6P9NB/+W+hmN2RO5UGVcGwKU2aTeOz8WuYAYGfnlSXxDE+6jRViE/JlW6nVDbx3pDF A7oha7vRjYx4Qzs1Q7YPa7KE95aRqg9YP/VifaS+wq2bqGMfaE55uV3yCLrMnMsJ4p8dy A9E2STuwiamz4UQ5OcG0lZ/Wfn4p6V65Ut22u0Z2hO3/ybchyidtJMi/7ltwxphi1AC/T XxU9DGiHQg8+wvuYnJnUYLLFZ+b+aU6qe6tHRvWhe1S/M55Mj/AH2r0KlOXAnXHCPxQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795531177; 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=1Fm3iLTzPKB1097UfAG40VRAoYU6YuWlhW7f4tKhwcE=; b=jzfneJvZq8qI3P4YM0Mtg85cK5gSZF8Hfwn+M137Y1jOIsONqwb/A3KF8lvHN5lNprXY N0BTB9uJMYF56+PByqWdsSATU2TtAY99Ttaqw79y7ryyE/5sVaINULdxktXHnF8JdSawT h815OYNEXkBtwBBOKjJRWdn5OpS3TqgCCiC4HvZTQCUDP+rylkDYCH6vOd0oLkDFaIXms GaQnDWWPW65mx0LUxed5ngFLHu/DhZhQ4gZsmihiQuNgGqvePo7g29uhVa1S8wX4K1t7b jV+3srvy62ubNVJpL1YWsQ6b4z7gH7+p2cWlo+66bc6r7fHJX1TGawdsTd9Ia0PY9iQ== 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="O5w/YPLH"; 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 CE649606A321; Tue, 24 Nov 2026 14:39:37 +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=O5w/YPLH 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=1795531172; b=WxWASI9b6r7So4/vN+hf9QIyveKqFOr3GB00hCLaXzzwLA6yIJl/VgimqFR4TpUyFUxt OOO2Y6PbzNjsJWSmX1GT1t0yarHxfPkBNOT3aW2Xb+uz48EDPFc883hYNabqSwEtSlMe0 1+wtybcm7FJd7TPkXsIZokTU9MorVrIuXpf1s1cr4znKm6eSLVEseFpTLkq5ixxhQp5TY ogVHqsydHL8qGw+dMC1+71SGJXA38fF9ENMfzboXq/Jx3JDOP1r8kzttkGdUIJZpTuyBx +AAr/7OSaxMZL4akAWv0CbEs+vtxQVyp/Z5vx+Q/J3kG+Ziey3O0yTqpZbfbvDHOvNA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795531172; 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=1Fm3iLTzPKB1097UfAG40VRAoYU6YuWlhW7f4tKhwcE=; b=PIjkYeYzNk5u1U4PFWei1FMeBjZvMuPn++GshKjJ7QEUfNYKdrrWJgPJcrqe1hSHolWa PpxpxbuFBvPCAXTe+kX9mlDvjgUmyxpjIbWChskSpabbwEjUJsdcBf+GKoYroy1tvgMTC 6dyvA7cwAPSlw8aWXJjT9+sMAOxp9Lxs000mdJOYFumXAXkBvueKSZa7eAwRXbgBRZd9i avQN8vlj2HPqNmcr7a/Awyxc2f3JNlFMKGqLa0ZA9p0G2c3RVUCVj1qvXn/KmsOTWxWS4 bYy3ohA6fUK30WKpFT0bJEnAVBjZaEekEFjl6AwRLbLV3tNRXB9bFB+NfbWscmyXYXQ== 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="O5w/YPLH"; 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 EC56C606A335; Tue, 24 Nov 2026 14:39:31 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFC681F000CA; Tue, 24 Nov 2026 14:39:30 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795531171; bh=1Fm3iLTzPKB1097UfAG40VRAoYU6YuWlhW7f4tKhwcE=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=O5w/YPLH5jeTeDCF330cgTourYPFekygkVQIRBT4tgRXcB7YUgJrbLxNxuwvkX8NX Gu6pBHAOluuqAWUJ5FPMpK80LZjDac/u0MhIGVXBFji09YLAiI8Q4BFbqJJdQmEIFw +ZSXUpGYEpnw35ZjjpK3ufRa3ek05nZyKXeKkjiUsyv5EvGn2BuFMjS3puWdvDEc6t wliEtQoEpAwMy3x7q4gBofsGYCdcY9sZqxjM3ti8Y1frrYTlSFSruq9Y16GZ8OC2UF ZtWWFd6QkAc0jE6JEmhvdd2fWymsgUDa2kSZIjMEYkSg3NX3+1KOlfa8tn6bywalI4 /kp84o+Gd0xWw== 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-4-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