From: Avinash Duduskar <avinash.duduskar@gmail.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Phil Sutter <phil@nwl.cc>, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft] evaluate: reject negative values for unsigned datatypes
Date: Sat, 15 Aug 2026 02:40:02 +0530 [thread overview]
Message-ID: <20260814211002.2812806-1-avinash.duduskar@gmail.com> (raw)
In-Reply-To: <an2_gW-ZhrAACQmb@chamomile>
On Thu, Aug 13, 2026 at 02:58:41PM +0200, Pablo Neira Ayuso wrote:
> Yes, I wonder if we can do this in a more generic way, like specifying
> in the datatype itself the min and maximum value expected from the
> integer.
Turns out the special case should not exist at all: it is dead code, so
neither the flag bit nor a validate callback would have a user here.
A negative priority never arrives at this check as a negative mpz. Bare
and json numeric priorities are built as raw C ints by both frontends,
priority_type_parse() throws away integer_type_parse()'s result and
rebuilds symbols from atoi(), and the name-plus-offset forms are
computed as C ints in evaluate_priority(). Instrumenting the top of
expr_evaluate_integer() agrees:
priority -300 (text) dtype=priority sgn=1 val=4294966996
prio: -300 (json) dtype=priority sgn=1 val=4294966996
element "-1" dtype=mark sgn=-1 val=-1
On min/max: both bounds this function enforces today come from the eval
context (ectx.maxval from numgen/hash, the mask from ectx.len), not from
the datatype, so a validate hook would sit beside them with no in-tree
user.
Dropping the special case also covers a third spelling of the bug found
while testing: "elem": [-1] as a json number is accepted today and
stored as element 1, like the string forms. The plain check rejects it
too.
v2 follows with the unconditional check and test arms for all three
forms plus flowtable priority. If the validate interface is wanted for
other reasons, I would do it as a separate patch on top.
Thanks,
Avinash
prev parent reply other threads:[~2026-08-14 21:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-08 1:33 [PATCH nft] evaluate: reject negative values for unsigned datatypes Avinash Duduskar
2026-08-13 11:21 ` Phil Sutter
2026-08-13 12:58 ` Pablo Neira Ayuso
2026-08-14 21:10 ` Avinash Duduskar [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=20260814211002.2812806-1-avinash.duduskar@gmail.com \
--to=avinash.duduskar@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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.