mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Cercueil <paul@crapouillou.net>
To: Nick Terrell <terrelln@fb.com>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
	od@zcrc.me, Paul Cercueil <paul@crapouillou.net>
Subject: [PATCH v2 1/2] lib: decompress_unzstd: Limit output size
Date: Tue, 25 Aug 2020 23:01:26 +0200	[thread overview]
Message-ID: <20200825210127.17850-1-paul@crapouillou.net> (raw)

The zstd decompression code, as it is right now, will have internal
values overflow on 32-bit systems when the output size is bigger than
1 GiB.

Until someone smarter than me can figure out how to fix the zstd code
properly, limit the destination buffer size to 1 GiB, which should be
enough for everybody, in order to make it usable on 32-bit systems.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Reviewed-by: Nick Terrell <terrelln@fb.com>
---

Notes:
    v2: Change limit to 1 GiB

 lib/decompress_unzstd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/decompress_unzstd.c b/lib/decompress_unzstd.c
index 0ad2c15479ed..414517baedb0 100644
--- a/lib/decompress_unzstd.c
+++ b/lib/decompress_unzstd.c
@@ -77,6 +77,7 @@
 
 #include <linux/decompress/mm.h>
 #include <linux/kernel.h>
+#include <linux/sizes.h>
 #include <linux/zstd.h>
 
 /* 128MB is the maximum window size supported by zstd. */
@@ -179,7 +180,7 @@ static int INIT __unzstd(unsigned char *in_buf, long in_len,
 	size_t ret;
 
 	if (out_len == 0)
-		out_len = LONG_MAX; /* no limit */
+		out_len = SZ_1G; /* should be big enough, right? */
 
 	if (fill == NULL && flush == NULL)
 		/*
-- 
2.28.0


             reply	other threads:[~2020-08-25 21:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-25 21:01 Paul Cercueil [this message]
2020-08-25 21:01 ` [PATCH v2 2/2] MIPS: Add support for ZSTD-compressed kernels Paul Cercueil
2020-08-26 15:51   ` kernel test robot
2020-08-25 22:51 ` [PATCH v2 1/2] lib: decompress_unzstd: Limit output size Nick Terrell

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=20200825210127.17850-1-paul@crapouillou.net \
    --to=paul@crapouillou.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=od@zcrc.me \
    --cc=terrelln@fb.com \
    --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®