diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-07-03 16:06:57 -0700 |
---|---|---|
committer | Ziyan <jaraidaniel@gmail.com> | 2016-01-05 18:21:54 +0100 |
commit | 4c4e1e40cb1a1d668edd76381a672685335a7f19 (patch) | |
tree | c1683502357578d4bcf01253d96d9e9116873d08 /lib | |
parent | 681e3c9d46aabd64d04792a24d91d65038b50fa4 (diff) | |
download | kernel_samsung_tuna-4c4e1e40cb1a1d668edd76381a672685335a7f19.zip kernel_samsung_tuna-4c4e1e40cb1a1d668edd76381a672685335a7f19.tar.gz kernel_samsung_tuna-4c4e1e40cb1a1d668edd76381a672685335a7f19.tar.bz2 |
lz4: add overrun checks to lz4_uncompress_unknownoutputsize()
Jan points out that I forgot to make the needed fixes to the
lz4_uncompress_unknownoutputsize() function to mirror the changes done
in lz4_decompress() with regards to potential pointer overflows.
The only in-kernel user of this function is the zram code, which only
takes data from a valid compressed buffer that it made itself, so it's
not a big issue. But due to external kernel modules using this
function, it's better to be safe here.
Reported-by: Jan Beulich <JBeulich@suse.com>
Cc: "Don A. Bailey" <donb@securitymouse.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lz4/lz4_decompress.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/lz4/lz4_decompress.c b/lib/lz4/lz4_decompress.c index b74da44..7a85967 100644 --- a/lib/lz4/lz4_decompress.c +++ b/lib/lz4/lz4_decompress.c @@ -192,6 +192,8 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest, int s = 255; while ((ip < iend) && (s == 255)) { s = *ip++; + if (unlikely(length > (size_t)(length + s))) + goto _output_error; length += s; } } @@ -232,6 +234,8 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest, if (length == ML_MASK) { while (ip < iend) { int s = *ip++; + if (unlikely(length > (size_t)(length + s))) + goto _output_error; length += s; if (s == 255) continue; @@ -284,7 +288,7 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest, /* write overflow error detected */ _output_error: - return (int) (-(((char *) ip) - source)); + return -1; } int lz4_decompress(const unsigned char *src, size_t *src_len, |