Commit 99b7e93c authored by Krzysztof Kolasa's avatar Krzysztof Kolasa Committed by Greg Kroah-Hartman

lz4: fix system halt at boot kernel on x86_64

Sometimes, on x86_64, decompression fails with the following
error:

Decompressing Linux...

Decoding failed

 -- System halted

This condition is not needed for a 64bit kernel(from commit d5e7cafd):

if( ... ||
    (op + COPYLENGTH) > oend)
    goto _output_error

macro LZ4_SECURE_COPY() tests op and does not copy any data
when op exceeds the value.

added by analogy to lz4_uncompress_unknownoutputsize(...)
Signed-off-by: default avatarKrzysztof Kolasa <kkolasa@winsoft.pl>
Tested-by: default avatarAlexander Kuleshov <kuleshovmail@gmail.com>
Tested-by: default avatarCaleb Jorden <cjorden@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 61a590fa
...@@ -140,8 +140,12 @@ static int lz4_uncompress(const char *source, char *dest, int osize) ...@@ -140,8 +140,12 @@ static int lz4_uncompress(const char *source, char *dest, int osize)
/* Error: request to write beyond destination buffer */ /* Error: request to write beyond destination buffer */
if (cpy > oend) if (cpy > oend)
goto _output_error; goto _output_error;
#if LZ4_ARCH64
if ((ref + COPYLENGTH) > oend)
#else
if ((ref + COPYLENGTH) > oend || if ((ref + COPYLENGTH) > oend ||
(op + COPYLENGTH) > oend) (op + COPYLENGTH) > oend)
#endif
goto _output_error; goto _output_error;
LZ4_SECURECOPY(ref, op, (oend - COPYLENGTH)); LZ4_SECURECOPY(ref, op, (oend - COPYLENGTH));
while (op < cpy) while (op < cpy)
...@@ -266,7 +270,13 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest, ...@@ -266,7 +270,13 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest,
if (cpy > oend - COPYLENGTH) { if (cpy > oend - COPYLENGTH) {
if (cpy > oend) if (cpy > oend)
goto _output_error; /* write outside of buf */ goto _output_error; /* write outside of buf */
#if LZ4_ARCH64
if ((ref + COPYLENGTH) > oend)
#else
if ((ref + COPYLENGTH) > oend ||
(op + COPYLENGTH) > oend)
#endif
goto _output_error;
LZ4_SECURECOPY(ref, op, (oend - COPYLENGTH)); LZ4_SECURECOPY(ref, op, (oend - COPYLENGTH));
while (op < cpy) while (op < cpy)
*op++ = *ref++; *op++ = *ref++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment