From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Phil Sutter <phil@nwl.cc>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [nft PATCH 4/4] evaluate: Avoid undefined behaviour in concat_subtype_id()
Date: Wed, 17 Aug 2016 16:51:27 +0200 [thread overview]
Message-ID: <20160817145127.GD10362@salvia> (raw)
In-Reply-To: <1471017610-3473-5-git-send-email-phil@nwl.cc>
On Fri, Aug 12, 2016 at 06:00:10PM +0200, Phil Sutter wrote:
> Looking at expr_evaluate_concat(), 'off' might be zero and the error
> checks not triggering (by having dtype != NULL and i->dtype->size > 0).
> Decrementing it will then lead to casting -1 to unsigned during the call
> to concat_subtype_lookup() will lead to bit-shifting in
> concat_subtype_id() by a value bigger than the number of bits in 'type'
> (which is 32bit).
>
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
> This patch is just an ugly sanitization hack and should probably be
> substituted by an additional error check in expr_evaluate_concat()
> giving an explanation of what went wrong.
I agree. It would be good to look back and see what condition can
indeed trigger this instead of papering the problem with this check.
Thanks!
> src/evaluate.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/evaluate.c b/src/evaluate.c
> index 523eedabe84ac..c8568690f6338 100644
> --- a/src/evaluate.c
> +++ b/src/evaluate.c
> @@ -950,7 +950,7 @@ static int expr_evaluate_concat(struct eval_ctx *ctx, struct expr **expr)
> "expressions",
> i->dtype->name);
>
> - tmp = concat_subtype_lookup(type, --off);
> + tmp = concat_subtype_lookup(type, off > 0 ? --off : 0);
> expr_set_context(&ctx->ectx, tmp, tmp->size);
>
> if (list_member_evaluate(ctx, &i) < 0)
> --
> 2.8.2
>
prev parent reply other threads:[~2016-08-17 14:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-12 16:00 [nft PATCH 0/4] A round of covscan indicated fixes Phil Sutter
2016-08-12 16:00 ` [nft PATCH 1/4] evaluate: Fix datalen checks in expr_evaluate_string() Phil Sutter
2016-08-17 14:41 ` Pablo Neira Ayuso
2016-08-12 16:00 ` [nft PATCH 2/4] netlink_delinearize: Avoid potential null pointer deref Phil Sutter
2016-08-17 14:46 ` Pablo Neira Ayuso
2016-08-12 16:00 ` [nft PATCH 3/4] proto_find_num: Avoid potential null pointer dereference Phil Sutter
2016-08-17 14:47 ` Pablo Neira Ayuso
2016-08-12 16:00 ` [nft PATCH 4/4] evaluate: Avoid undefined behaviour in concat_subtype_id() Phil Sutter
2016-08-17 14:51 ` 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=20160817145127.GD10362@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 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.