mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-10-26 10:57:38 +08:00
lib/842: require a complete history block for repeat templates
An 842 repeat template copies the preceding eight-byte output block. The
decoder rejects a repeat only when no output has been produced. A
short-data operation can produce between one and seven bytes before a
repeat.
Such a stream makes the repeat copy read before the start of the output
buffer. Depending on the surrounding mapping, this can fault or bring
preceding memory into the decompressed data.
This is also reachable through zram's compressed writeback path. With 842
selected, targeted corruption of the compressed data on its backing device
to a short-data-then-repeat stream made a KASAN kernel report a
vmalloc-out-of-bounds read when zram read the page back.
Require at least one complete output block before accepting a repeat.
Fixes: 2da572c959 ("lib: add software 842 compression/decompression")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
1 parent
38ed7182f3
commit
deb6316498
1 file changed
+1
-1
@@ -309,7 +309,7 @@ int sw842_decompress(const u8 *in, unsigned int ilen,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (p.out == out) /* no previous bytes */
|
||||
if (p.out - p.ostart < 8) /* no complete previous block */
|
||||
return -EINVAL;
|
||||
|
||||
/* copy rep + 1 */
|
||||
|
||||
Reference in new issue
Block a user