All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] lib: decompress_unzstd: Limit output size
@ 2020-08-21 16:29 Paul Cercueil
  2020-08-21 16:29 ` [PATCH 2/2] MIPS: Add support for ZSTD-compressed kernels Paul Cercueil
  2020-08-24 20:11 ` [PATCH 1/2] lib: decompress_unzstd: Limit output size Nick Terrell
  0 siblings, 2 replies; 8+ messages in thread
From: Paul Cercueil @ 2020-08-21 16:29 UTC (permalink / raw)
  To: Nick Terrell, Thomas Bogendoerfer
  Cc: linux-mips, linux-kernel, od, Paul Cercueil

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

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

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 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..e1c03b1eaa6e 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_512M; /* should be big enough, right? */
 
 	if (fill == NULL && flush == NULL)
 		/*
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-08-24 21:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-21 16:29 [PATCH 1/2] lib: decompress_unzstd: Limit output size Paul Cercueil
2020-08-21 16:29 ` [PATCH 2/2] MIPS: Add support for ZSTD-compressed kernels Paul Cercueil
2020-08-24 19:51   ` Nick Terrell
2020-08-24 21:02     ` Paul Cercueil
2020-08-24 21:45       ` Nick Terrell
2020-08-24 20:11 ` [PATCH 1/2] lib: decompress_unzstd: Limit output size Nick Terrell
2020-08-24 21:05   ` Paul Cercueil
2020-08-24 21:50     ` Nick Terrell

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.