netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org, phil@nwl.cc
Subject: Re: [PATCH nf] netfilter: nf_tables: set pktinfo->thoff at AH header if found
Date: Sat, 4 Mar 2017 23:58:17 +0100	[thread overview]
Message-ID: <20170304225817.GA1023@salvia> (raw)
In-Reply-To: <20170304194342.GA6457@breakpoint.cc>

On Sat, Mar 04, 2017 at 08:43:42PM +0100, Florian Westphal wrote:
> Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > Phil Sutter reports that IPv6 AH header matching is broken. From
> > userspace, nft generates bytecode that expects to find the AH header at
> > NFT_PAYLOAD_TRANSPORT_HEADER both for IPv4 and IPv6. However,
> > pktinfo->thoff is set to the inner header after the AH header in IPv6,
> > while in IPv4 pktinfo->thoff points to the AH header indeed. This
> > behaviour is inconsistent. This patch fixes this problem by updating
> > ipv6_find_hdr() to get the IP6_FH_F_AUTH flag so this function stops at
> > the AH header, so both IPv4 and IPv6 pktinfo->thoff point to the AH
> > header.
> 
> This looks wrong.  We need to search until we find a l4 header,
> after this patch "tcp dort 22" won't match anymore if an AH header
> exists.

Look Florian:

# nft --debug=netlink add rule inet x y tcp dport 22 counter
inet x y 
  [ meta load l4proto => reg 1 ]
  [ cmp eq reg 1 0x00000006 ]
  [ payload load 2b @ transport header + 2 => reg 1 ]
  [ cmp eq reg 1 0x00001600 ]
  [ counter pkts 0 bytes 0 ]

<cmdline>:1:1-39: Error: Could not process rule: No such file or directory

If we leave things the way they are:

1) A packet that looks like IPv4 + AH + TCP dport 22 will match.
2) A packet that looks like IPv6 + AH + TCP dport 22 will *not* match.

If you really want to keep this inconsistent behaviour around, I let
you inaugurate the errata section of the nft manpage ;-)

Seriously, I think it's better if we just fix this and focus on
designing a way to match at inner headers if you really need to match
on tcp ports encapsulated in ah traffic.

  reply	other threads:[~2017-03-04 22:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-04 18:53 [PATCH nf] netfilter: nf_tables: set pktinfo->thoff at AH header if found Pablo Neira Ayuso
2017-03-04 19:43 ` Florian Westphal
2017-03-04 22:58   ` Pablo Neira Ayuso [this message]
2017-03-04 23:16     ` 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=20170304225817.GA1023@salvia \
    --to=pablo@netfilter.org \
    --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 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).