From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Fernando Fernandez Mancera <fmancera@suse.de>
Cc: netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
ecklm94@gmail.com, phil@nwl.cc, fw@strlen.de
Subject: Re: [PATCH 2/2 nf v2] netfilter: xtables: fix L4 header parsing for non-first fragments
Date: Mon, 20 Apr 2026 22:58:26 +0200 [thread overview]
Message-ID: <aeaTcpPAk1HDjUoD@chamomile> (raw)
In-Reply-To: <aeaQcrEMN-IYE7xI@chamomile>
On Mon, Apr 20, 2026 at 10:45:41PM +0200, Pablo Neira Ayuso wrote:
> Hi Fernando,
>
> On Mon, Apr 20, 2026 at 12:47:45PM +0200, Fernando Fernandez Mancera wrote:
> > diff --git a/net/netfilter/xt_socket.c b/net/netfilter/xt_socket.c
> > index 76e01f292aaf..d366e294f1aa 100644
> > --- a/net/netfilter/xt_socket.c
> > +++ b/net/netfilter/xt_socket.c
> > @@ -55,8 +55,11 @@ socket_match(const struct sk_buff *skb, struct xt_action_param *par,
> > if (sk && !net_eq(xt_net(par), sock_net(sk)))
> > sk = NULL;
> >
> > - if (!sk)
> > + if (!sk) {
> > + if (par->fragoff)
> > + return false;
> > sk = nf_sk_lookup_slow_v4(xt_net(par), skb, xt_in(par));
> > + }
> >
> > if (sk) {
> > bool wildcard;
> > @@ -116,8 +119,11 @@ socket_mt6_v1_v2_v3(const struct sk_buff *skb, struct xt_action_param *par)
> > if (sk && !net_eq(xt_net(par), sock_net(sk)))
> > sk = NULL;
> >
> > - if (!sk)
> > + if (!sk) {
> > + if (par->fragoff)
> > + return false;
>
> Your patch will work as intented in iptables over nf_tables, because
> it always sets on fragoff regardless user policy.
>
> But, if ipv6_find_hdr() finds no layer 4 protocol, then fragoff
> remains zero, and pkt->flags does not set on NFT_PKTINFO_L4PROTO.
> There, in nftables, par->fragoff but itself is not reliable because
> maybe the layer 4 was not found.
This is where pkt->tprot comes into play. I think this series is fine
with nf_tables, it is just ip6_tables legacy that lags behind.
> Then, there is ip6_tables legacy which does not behave like ip_tables
> for fragments.
>
> ip6t_do_table() only sets fragoff if IP6T_F_PROTO (-p in userspace) is
> used, unlike nftables which always sets on fragoff.
>
> So par->fragoff is unreliable in ip6_tables legacy, and
> ipv6_find_hdr() is called over and over again ip6_packet_match() loop
> for each rule.
>
> One way would be to call ipv6_find_hdr() inconditionally from
> ip6_tables legacy, but that belongs to a different patch and that
> would be touch core ip6_tables legacy.
>
> Rewinding a bit, coming to back to the original issue: osf only
> supports ipv4 :-)
>
> > sk = nf_sk_lookup_slow_v6(xt_net(par), skb, xt_in(par));
> > + }
> >
> > if (sk) {
> > bool wildcard;
> > diff --git a/net/netfilter/xt_tcpmss.c b/net/netfilter/xt_tcpmss.c
> > index 0d32d4841cb3..69844cc8dbb8 100644
> > --- a/net/netfilter/xt_tcpmss.c
> > +++ b/net/netfilter/xt_tcpmss.c
> > @@ -32,6 +32,9 @@ tcpmss_mt(const struct sk_buff *skb, struct xt_action_param *par)
> > u8 _opt[15 * 4 - sizeof(_tcph)];
> > unsigned int i, optlen;
> >
> > + if (par->fragoff)
> > + return false;
> > +
> > /* If we don't have the whole header, drop packet. */
> > th = skb_header_pointer(skb, par->thoff, sizeof(_tcph), &_tcph);
> > if (th == NULL)
> > --
> > 2.53.0
> >
next prev parent reply other threads:[~2026-04-20 20:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 10:47 [PATCH 1/2 nf v2] netfilter: nf_tables: skip L4 header parsing for non-first fragments Fernando Fernandez Mancera
2026-04-20 10:47 ` [PATCH 2/2 nf v2] netfilter: xtables: fix " Fernando Fernandez Mancera
2026-04-20 20:45 ` Pablo Neira Ayuso
2026-04-20 20:58 ` Pablo Neira Ayuso [this message]
2026-04-20 21:08 ` Fernando Fernandez Mancera
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=aeaTcpPAk1HDjUoD@chamomile \
--to=pablo@netfilter.org \
--cc=coreteam@netfilter.org \
--cc=ecklm94@gmail.com \
--cc=fmancera@suse.de \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.