From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft] json: fix error protagation when parsing binop lhs/rhs
Date: Mon, 31 Mar 2025 12:22:52 +0200 [thread overview]
Message-ID: <Z-ps_B-vTcI3O-R3@calendula> (raw)
In-Reply-To: <20250328144911.21966-1-fw@strlen.de>
On Fri, Mar 28, 2025 at 03:49:04PM +0100, Florian Westphal wrote:
> Malformed input returns NULL when decoding left/right side of binop.
> This causes a NULL dereference in expr_evaluate_binop; left/right must
> point to a valid expression.
>
> Fix this in the parser, else would have to sprinkle NULL checks all over
> the evaluation code.
>
> After fix, loading the bogon yields:
> internal:0:0-0: Error: Malformed object (too many properties): '{}'.
> internal:0:0-0: Error: could not decode binop rhs, '<<'.
> internal:0:0-0: Error: Invalid mangle statement value
> internal:0:0-0: Error: Parsing expr array at index 1 failed.
> internal:0:0-0: Error: Parsing command array at index 3 failed.
>
> Fixes: 0ac39384fd9e ("json: Accept more than two operands in binary expressions")
> Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
one nitpick:
> diff --git a/tests/shell/testcases/bogons/nft-j-f/binop_rhs_decode_error_crash b/tests/shell/testcases/bogons/nft-j-f/binop_rhs_decode_error_crash
> new file mode 100644
> index 000000000000..c5de17111ff6
> --- /dev/null
> +++ b/tests/shell/testcases/bogons/nft-j-f/binop_rhs_decode_error_crash
[...]
> + "value": {
> + "<<": [
> + {
> + "|": [
> + {
> + "meta": {
> + "key": "mark"
> + }
> + },
> + 16
> + ]
> + },
> + { },
Something strange here in this indent.
> + 8
> + ]
> + }
> + }
> + }
> + ]
> + }
> + }
> + ]
> +}
prev parent reply other threads:[~2025-03-31 10:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-28 14:49 [PATCH nft] json: fix error protagation when parsing binop lhs/rhs Florian Westphal
2025-03-31 10:22 ` 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=Z-ps_B-vTcI3O-R3@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 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).