From: Greg Kroah-Hartman Date: Sat, 21 Jun 2014 05:01:41 +0000 (-0700) Subject: lz4: ensure length does not wrap X-Git-Tag: v3.16-rc3~11^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=206204a1162b995e2185275167b22468c00d6b36;p=platform%2Fkernel%2Flinux-exynos.git lz4: ensure length does not wrap Given some pathologically compressed data, lz4 could possibly decide to wrap a few internal variables, causing unknown things to happen. Catch this before the wrapping happens and abort the decompression. Reported-by: "Don A. Bailey" Cc: stable Signed-off-by: Greg Kroah-Hartman --- diff --git a/lib/lz4/lz4_decompress.c b/lib/lz4/lz4_decompress.c index df6839e..99a03ac 100644 --- a/lib/lz4/lz4_decompress.c +++ b/lib/lz4/lz4_decompress.c @@ -72,6 +72,8 @@ static int lz4_uncompress(const char *source, char *dest, int osize) len = *ip++; for (; len == 255; length += 255) len = *ip++; + if (unlikely(length > (size_t)(length + len))) + goto _output_error; length += len; }