From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Peter Tirsek <peter@tirsek.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [nft PATCH] evaluate: fix segfault when adding elements to invalid set
Date: Mon, 27 Jun 2022 12:19:22 +0200 [thread overview]
Message-ID: <YrmEKowjcFRxfhLd@salvia> (raw)
In-Reply-To: <8665536e-5724-ec18-60e8-685deb086649@wolfie.tirsek.com>
On Sun, Jun 26, 2022 at 12:47:07AM -0500, Peter Tirsek wrote:
> Adding elements to a set or map with an invalid definition causes nft to
> segfault. The following nftables.conf triggers the crash:
>
> flush ruleset
> create table inet filter
> set inet filter foo {}
> add element inet filter foo { foobar }
>
> Simply parsing and checking the config will trigger it:
>
> $ nft -c -f nftables.conf.crash
> Segmentation fault
>
> The error in the set/map definition is correctly caught and queued, but
> because the set is invalid and does not contain a key type, adding to it
> causes a NULL pointer dereference of set->key within setelem_evaluate().
>
> I don't think it's necessary to queue another error since the underlying
> problem is correctly detected and reported when parsing the definition
> of the set. Simply checking the validity of set->key before using it
> seems to fix it, causing the error in the definition of the set to be
> reported properly. The element type error isn't caught, but that seems
> reasonable since the key type is invalid or unknown anyway:
>
> $ ./nft -c -f ~/nftables.conf.crash
> /home/pti/nftables.conf.crash:3:21-21: Error: set definition does not specify key
> set inet filter foo {}
> ^
Applied, thanks
prev parent reply other threads:[~2022-06-27 10:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-26 5:47 [nft PATCH] evaluate: fix segfault when adding elements to invalid set Peter Tirsek
2022-06-27 10:19 ` Pablo Neira Ayuso [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=YrmEKowjcFRxfhLd@salvia \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=peter@tirsek.com \
/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).