netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Phil Sutter <phil@nwl.cc>, netfilter-devel@vger.kernel.org
Subject: Re: [nft PATCH] evaluate: Reject quoted strings containing only wildcard
Date: Wed, 30 Sep 2020 12:20:33 +0200	[thread overview]
Message-ID: <20200930102033.GA18726@salvia> (raw)
In-Reply-To: <20200928081925.GZ19674@orbyte.nwl.cc>

On Mon, Sep 28, 2020 at 10:19:25AM +0200, Phil Sutter wrote:
> On Thu, Sep 24, 2020 at 07:06:39PM +0200, Phil Sutter wrote:
> > Fix for an assertion fail when trying to match against an all-wildcard
> > interface name:
> > 
> > | % nft add rule t c iifname '"*"'
> > | nft: expression.c:402: constant_expr_alloc: Assertion `(((len) + (8) - 1) / (8)) > 0' failed.
> > | zsh: abort      nft add rule t c iifname '"*"'
> > 
> > Fix this by detecting the string in expr_evaluate_string() and returning
> > an error message:
> > 
> > | % nft add rule t c iifname '"*"'
> > | Error: All-wildcard strings are not supported
> > | add rule t c iifname "*"
> > |                      ^^^
> > 
> 
> Note that all this is pretty inconsistent: The above happens only for
> quoted asterisks. Unquoted ones cause a different error (at least no
> assertion fail):
> 
> | % nft add rule t c iifname '*'
> | Error: datatype mismatch, expected network interface name, expression has type integer
> | add rule t c iifname *
> |              ~~~~~~~ ^
> 
> What puzzles me is that we have:
> 
> | wildcard_expr           :       ASTERISK
> |                         {
> |                                 struct expr *expr;
> | 
> |                                 expr = constant_expr_alloc(&@$, &integer_type,
> |                                                            BYTEORDER_HOST_ENDIAN,
> |                                                            0, NULL);
> |                                 $$ = prefix_expr_alloc(&@$, expr, 0);
> |                         }
> |                         ;
> 
> Yet when trying to use it as a prefix, it is rejected:
> 
> | % nft add rule t c ip saddr '*'
> | Error: datatype mismatch, expected IPv4 address, expression has type integer
> | add rule t c ip saddr *
> |              ~~~~~~~~ ^
> 
> So is this wildcard_expr simply broken or didn't I find correct way to use it
> yet?

This looks like some preliminary support for wildcard matching in set
elements, but my impression is that this is broken. I don't remember
to have seen any tests covering this.

  reply	other threads:[~2020-09-30 10:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-24 17:06 [nft PATCH] evaluate: Reject quoted strings containing only wildcard Phil Sutter
2020-09-28  8:19 ` Phil Sutter
2020-09-30 10:20   ` Pablo Neira Ayuso [this message]
2020-12-17 14:23     ` Phil Sutter
2020-12-17 14:32       ` Pablo Neira Ayuso

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=20200930102033.GA18726@salvia \
    --to=pablo@netfilter.org \
    --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).