netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Andrii Melnychenko <a.melnychenko@vyos.io>
Cc: pablo@netfilter.org, kadlec@netfilter.org, phil@nwl.cc,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1] nf_conntrack_ftp: Added nfct_seqadj_ext_add() for ftp's conntrack.
Date: Thu, 16 Oct 2025 13:20:10 +0200	[thread overview]
Message-ID: <aPDU6i1HKhy5v-nh@strlen.de> (raw)
In-Reply-To: <20251016104802.567812-2-a.melnychenko@vyos.io>

Andrii Melnychenko <a.melnychenko@vyos.io> wrote:
> There was an issue with NAT'ed ftp and replaced messages
> for PASV/EPSV mode. "New" IP in the message may have a
> different length that would require sequence adjustment.
> 
> Signed-off-by: Andrii Melnychenko <a.melnychenko@vyos.io>
> ---
>  net/netfilter/nf_conntrack_ftp.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/net/netfilter/nf_conntrack_ftp.c b/net/netfilter/nf_conntrack_ftp.c
> index 617f744a2..0216bc099 100644
> --- a/net/netfilter/nf_conntrack_ftp.c
> +++ b/net/netfilter/nf_conntrack_ftp.c
> @@ -25,6 +25,7 @@
>  #include <net/netfilter/nf_conntrack_ecache.h>
>  #include <net/netfilter/nf_conntrack_helper.h>
>  #include <linux/netfilter/nf_conntrack_ftp.h>
> +#include <net/netfilter/nf_conntrack_seqadj.h>
>  
>  #define HELPER_NAME "ftp"
>  
> @@ -390,6 +391,8 @@ static int help(struct sk_buff *skb,
>  	/* Until there's been traffic both ways, don't look in packets. */
>  	if (ctinfo != IP_CT_ESTABLISHED &&
>  	    ctinfo != IP_CT_ESTABLISHED_REPLY) {
> +		if (!nf_ct_is_confirmed(ct))
> +			nfct_seqadj_ext_add(ct);

Still not convinced this is the correct place.

In nf_nat_setup_info we have:

                if (nfct_help(ct) && !nfct_seqadj(ct))
                        if (!nfct_seqadj_ext_add(ct))
                                return NF_DROP;

Looking at your cover letter (some of that info should be in
patch changelog, it provides essential context), I would say
that dnat rule is evaluated before the helper gets attached.

If so, the bug is in nft_ct_helper_obj_eval, and the Fixes
tag should be set to

Fixes: 1a64edf54f55 ("netfilter: nft_ct: add helper set support")

Probably something like:

if ((ct->status & IPS_NAT_MASK) && !!nfct_seqadj(ct))
	if (!nfct_seqadj_ext_add(ct)) ...

Could you please investigate a bit futher? To me it looks
like all other helpers have the same issue, a generic fix would
be better.

  reply	other threads:[~2025-10-16 11:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-16 10:48 [PATCH v2 0/1] nf_conntrack_ftp: Added nfct_seqadj_ext_add() Andrii Melnychenko
2025-10-16 10:48 ` [PATCH v2 1/1] nf_conntrack_ftp: Added nfct_seqadj_ext_add() for ftp's conntrack Andrii Melnychenko
2025-10-16 11:20   ` Florian Westphal [this message]
     [not found]     ` <CANhDHd-k2Ros8nFo4fNi=-Mu1DxkK4A2MgLYjuDqPwpfJYYfdw@mail.gmail.com>
2025-10-20 14:20       ` Florian Westphal

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=aPDU6i1HKhy5v-nh@strlen.de \
    --to=fw@strlen.de \
    --cc=a.melnychenko@vyos.io \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kadlec@netfilter.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=phil@nwl.cc \
    /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;
as well as URLs for NNTP newsgroup(s).