netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [nft PATCH] evaluate: Reject set references in mapping LHS
Date: Thu, 14 Nov 2019 11:52:25 +0100	[thread overview]
Message-ID: <20191114105225.GG11663@orbyte.nwl.cc> (raw)
In-Reply-To: <20191113231022.bb7hmwqvmgm4emv7@salvia>

On Thu, Nov 14, 2019 at 12:10:22AM +0100, Pablo Neira Ayuso wrote:
> On Wed, Nov 13, 2019 at 11:10:50AM +0100, Phil Sutter wrote:
> > On Tue, Nov 12, 2019 at 11:18:27PM +0100, Phil Sutter wrote:
> > > On Tue, Nov 12, 2019 at 10:45:18PM +0100, Pablo Neira Ayuso wrote:
> > > > On Thu, Oct 31, 2019 at 07:21:24PM +0100, Phil Sutter wrote:
> > > > > This wasn't explicitly caught before causing a program abort:
> > > > > 
> > > > > | BUG: invalid range expression type set reference
> > > > > | nft: expression.c:1162: range_expr_value_low: Assertion `0' failed.
> > > > > | zsh: abort      sudo ./install/sbin/nft add rule t c meta mark set tcp dport map '{ @s : 23 }
> > > > > 
> > > > > With this patch in place, the error message is way more descriptive:
> > > > > 
> > > > > | Error: Key can't be set reference
> > > > > | add rule t c meta mark set tcp dport map { @s : 23 }
> > > > > |                                            ^^
> > > > 
> > > > I wanted to check why the parser allow for this...
> > > 
> > > For set elements or LHS parts of map elements, there is set_lhs_expr.
> > > The latter may be concat_rhs_expr or multiton_rhs_expr. concat_rhs_expr
> > > eventually resolves into primary_rhs_expr which may be symbol_expr.
> > > 
> > > BTW, it seems like from parser side, set references on map element's
> > > RHS are allowed as well.
> > > 
> > > IMHO, parser_bison.y slowly but steadily turns into a can of worms. :(
> > 
> > On a second look, I start wondering whether symbol_expr was a wise
> > choice: This thing combines variables ('$' identifier), "unidentified"
> > strings and set references (AT identifier).
> > 
> > With symbol_expr being listed in both primary_expr and primary_rhs_expr,
> > set references are allowed about anywhere - even in concatenations or
> > any binary operation.
> 
> It would be probably good to restrict set references to where it makes
> sense only. This is good for the grammar and we don't need to validate
> all possible invalid combinations from the evaluation step.

ACK!

> Would you have a look or you think it's too complicated to attack this
> from the parser?

It's not too complicated, but I sometimes feel like turning adjuster
screws on a machine I don't understand. OK, given that parser_bison.y
was initially written by Patrick, you're probably in the same situation.
:)

Cheers, Phil

      reply	other threads:[~2019-11-14 10:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-31 18:21 [nft PATCH] evaluate: Reject set references in mapping LHS Phil Sutter
2019-11-12 21:45 ` Pablo Neira Ayuso
2019-11-12 22:18   ` Phil Sutter
2019-11-13 10:10     ` Phil Sutter
2019-11-13 23:10       ` Pablo Neira Ayuso
2019-11-14 10:52         ` Phil Sutter [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=20191114105225.GG11663@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --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;
as well as URLs for NNTP newsgroup(s).