From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft] evaluate: avoid double-free on error handling of bogus objref maps
Date: Wed, 25 Jun 2025 23:19:25 +0200 [thread overview]
Message-ID: <aFxn3Q9SFnsOkWYg@calendula> (raw)
In-Reply-To: <20250624212101.18722-1-fw@strlen.de>
On Tue, Jun 24, 2025 at 11:20:58PM +0200, Florian Westphal wrote:
> commit 98c51aaac42b ("evaluate: bail out if anonymous concat set defines a non concat expression")
> clears set->init to avoid a double-free.
>
> Extend this to also handle object maps.
> The included bogon triggers a double-free of set->init expression:
>
> Error: unqualified type invalid specified in map definition. Try "typeof expression" instead of "type datatype".
> ct helper set ct saddr map { 1c3:: : "p", dead::beef : "myftp" }
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> This might not crash, depending on libc/malloc, but ASAN reports this:
> ==17728==ERROR: AddressSanitizer: heap-use-after-free on address 0x50b0000005e8 at ..
> READ of size 4 at 0x50b0000005e8 thread T0
> #0 0x7f1be3cb7526 in expr_free src/expression.c:87
> #1 0x7f1be3cbdf29 in map_expr_destroy src/expression.c:1488
> #2 0x7f1be3cb74d5 in expr_destroy src/expression.c:80
> #3 0x7f1be3cb75c6 in expr_free src/expression.c:96
> #4 0x7f1be3d5925e in objref_stmt_destroy src/statement.c:331
> #5 0x7f1be3d5831f in stmt_free src/statement.c:56
> #6 0x7f1be3d583c2 in stmt_list_free src/statement.c:66
> #7 0x7f1be3d42805 in rule_free src/rule.c:495
> #8 0x7f1be3d48329 in cmd_free src/rule.c:1417
> #9 0x7f1be3cd2c7c in __nft_run_cmd_from_filename src/libnftables.c:759
> #10 0x7f1be3cd340c in nft_run_cmd_from_filename src/libnftables.c:847
> #11 0x55dcde0440be in main src/main.c:535
>
> Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
prev parent reply other threads:[~2025-06-25 21:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-24 21:20 [PATCH nft] evaluate: avoid double-free on error handling of bogus objref maps Florian Westphal
2025-06-25 21: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=aFxn3Q9SFnsOkWYg@calendula \
--to=pablo@netfilter.org \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.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 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.