From: Nick Terrell <terrelln@fb.com>
To: Paul Cercueil <paul@crapouillou.net>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
"od@zcrc.me" <od@zcrc.me>,
"linux-mips@vger.kernel.org" <linux-mips@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 1/2] lib: decompress_unzstd: Limit output size
Date: Tue, 1 Sep 2020 22:42:08 +0000 [thread overview]
Message-ID: <747B4847-08E5-40C9-927B-E1BAC057CF46@fb.com> (raw)
In-Reply-To: <20200901142651.1165237-2-paul@crapouillou.net>
> On Sep 1, 2020, at 7:26 AM, Paul Cercueil <paul@crapouillou.net> wrote:
>
> The zstd decompression code, as it is right now, will most likely fail
> on 32-bit systems, as the default output buffer size causes the buffer's
> end address to overflow.
>
> Address this issue by setting a sane default to the default output size,
> with a value that won't overflow the buffer's end address.
>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>
> Notes:
> v2: Change limit to 1 GiB
>
> v3: Compute size limit instead of using hardcoded value
>
> lib/decompress_unzstd.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/lib/decompress_unzstd.c b/lib/decompress_unzstd.c
> index 0ad2c15479ed..790abc472f5b 100644
> --- a/lib/decompress_unzstd.c
> +++ b/lib/decompress_unzstd.c
> @@ -178,8 +178,13 @@ static int INIT __unzstd(unsigned char *in_buf, long in_len,
> int err;
> size_t ret;
>
> + /*
> + * ZSTD decompression code won't be happy if the buffer size is so big
> + * that its end address overflows. When the size is not provided, make
> + * it as big as possible without having the end address overflow.
> + */
> if (out_len == 0)
> - out_len = LONG_MAX; /* no limit */
> + out_len = UINTPTR_MAX - (uintptr_t)out_buf;
Great, that works for me. Thanks for fixing this!
Reviewed-by: Nick Terrell <terrelln@fb.com>
> if (fill == NULL && flush == NULL)
> /*
> --
> 2.28.0
>
next prev parent reply other threads:[~2020-09-01 22:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-01 14:26 [PATCH v3 0/2] MIPS: Add support for ZSTD v3 Paul Cercueil
2020-09-01 14:26 ` [PATCH v3 1/2] lib: decompress_unzstd: Limit output size Paul Cercueil
2020-09-01 22:42 ` Nick Terrell [this message]
2020-09-01 14:26 ` [PATCH v3 2/2] MIPS: Add support for ZSTD-compressed kernels Paul Cercueil
2020-09-03 8:16 ` [PATCH v3 0/2] MIPS: Add support for ZSTD v3 Thomas Bogendoerfer
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=747B4847-08E5-40C9-927B-E1BAC057CF46@fb.com \
--to=terrelln@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=od@zcrc.me \
--cc=paul@crapouillou.net \
--cc=tsbogend@alpha.franken.de \
/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
all inboxes | Powered by JetHome®