squashfs: more metadata hardening
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 30 Jul 2018 21:27:15 +0000 (14:27 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 31 Jul 2018 00:29:17 +0000 (17:29 -0700)
Anatoly reports another squashfs fuzzing issue, where the decompression
parameters themselves are in a compressed block.

This causes squashfs_read_data() to be called in order to read the
decompression options before the decompression stream having been set
up, making squashfs go sideways.

Reported-by: Anatoly Trosinenko <anatoly.trosinenko@gmail.com>
Acked-by: Phillip Lougher <phillip.lougher@gmail.com>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/squashfs/block.c

index 2751476e6b6e85e094b33f717093ba0251af999e..f098b9f1c3963b77c2112d7f4342f58ccca4f192 100644 (file)
@@ -167,6 +167,8 @@ int squashfs_read_data(struct super_block *sb, u64 index, int length,
        }
 
        if (compressed) {
+               if (!msblk->stream)
+                       goto read_failure;
                length = squashfs_decompress(msblk, bh, b, offset, length,
                        output);
                if (length < 0)