From: Stefano Brivio <sbrivio@redhat.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org, fw@strlen.de
Subject: Re: [PATCH] segtree: bail out on concatenations
Date: Fri, 3 Apr 2020 16:12:02 +0200 [thread overview]
Message-ID: <20200403161202.4d1b2322@elisabeth> (raw)
In-Reply-To: <20200403153331.53e1bbec@elisabeth>
On Fri, 3 Apr 2020 15:33:31 +0200
Stefano Brivio <sbrivio@redhat.com> wrote:
> On Fri, 3 Apr 2020 14:50:29 +0200
> Pablo Neira Ayuso <pablo@netfilter.org> wrote:
>
> > On Fri, Apr 03, 2020 at 02:27:05PM +0200, Stefano Brivio wrote:
> > > On Fri, 3 Apr 2020 14:03:51 +0200
> > > Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > >
> > > > On Thu, Apr 02, 2020 at 11:49:41PM +0200, Pablo Neira Ayuso wrote:
> > > > > This patch adds a lazy check to validate that the first element is not a
> > > > > concatenation. The segtree code does not support for concatenations,
> > > > > bail out with EOPNOTSUPP.
> > > > >
> > > > > # nft add element x y { 10.0.0.0/8 . 192.168.1.3-192.168.1.9 . 1024-65535 }
> > > > > Error: Could not process rule: Operation not supported
> > > > > add element x y { 10.0.0.0/8 . 192.168.1.3-192.168.1.9 . 1024-65535 }
> > > > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > > > >
> > > > > Otherwise, the segtree code barfs with:
> > > > >
> > > > > BUG: invalid range expression type concat
> > > >
> > > > Hm.
> > > >
> > > > I'm afraid this patch is not enough, the following ruleset crashes
> > > > in old kernels with recent nft:
> > > >
> > > > flush ruleset
> > > >
> > > > table inet filter {
> > > > set test {
> > > > type ipv4_addr . ipv4_addr . inet_service
> > > > flags interval,timeout
> > > > elements = { 1.1.1.1 . 2.2.2.2 . 30 ,
> > > > 2.2.2.2 . 3.3.3.3 . 40 ,
> > > > 3.3.3.3 . 4.4.4.4 . 50 }
> > > > }
> > > >
> > > > chain output {
> > > > type filter hook output priority 0; policy accept;
> > > > ip saddr . ip daddr . tcp dport @test counter
> > > > }
> > > > }
> > >
> > > First off, sorry, it didn't occur to me to run new tests on older
> > > kernels. :/
> > >
> > > I can't quickly run that on some older kernel right now. For my
> > > understanding, where is it crashing?
> >
> > When listing via
> >
> > nft list ruleset
> >
> > The segtree does not know how to handle this concatenation.
>
> Ouch, I see.
>
> > The only way I found to prevent this error is to bail out when adding
> > the set, ie. old kernel checks that NFT_SET_CONCAT is not supported,
> > hence it bails out.
>
> Right, it took me a while to realise you're referring to the flag that
> was present until v2 and I dropped in v3 (gold medal goes to truly
> yours -- I actually proposed that :/).
>
> > I'm going to prepare patches to submit this to nf.git.
>
> I'm still wondering if we can come up with a userspace-only fix by
> understanding kernel support level somehow (not via flags) and refuse
> to add that type of set. I'm still checking.
Nope, sorry, I can't think of anything better than what you already
proposed.
--
Stefano
prev parent reply other threads:[~2020-04-03 14:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-02 21:49 [PATCH] segtree: bail out on concatenations Pablo Neira Ayuso
2020-04-03 0:54 ` Stefano Brivio
2020-04-03 10:39 ` Pablo Neira Ayuso
2020-04-03 10:43 ` Stefano Brivio
2020-04-03 12:03 ` Pablo Neira Ayuso
2020-04-03 12:05 ` Pablo Neira Ayuso
2020-04-03 12:27 ` Stefano Brivio
2020-04-03 12:50 ` Pablo Neira Ayuso
2020-04-03 13:33 ` Stefano Brivio
2020-04-03 14:12 ` Stefano Brivio [this message]
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=20200403161202.4d1b2322@elisabeth \
--to=sbrivio@redhat.com \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/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