squashfs: be more careful about metadata corruption
Anatoly Trosinenko reports that a corrupted squashfs image can cause a kernel oops. It turns out that squashfs can end up being confused about negative fragment lengths. The regular squashfs_read_data() does check for negative lengths, but squashfs_read_metadata() did not, and the fragment size code just blindly trusted the on-disk value. Fix both the fragment parsing and the metadata reading code. Reported-by: Anatoly Trosinenko <anatoly.trosinenko@gmail.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Phillip Lougher <phillip@squashfs.org.uk> Cc: stable@kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
@@ -129,6 +129,12 @@
|
||||
|
||||
#define SQUASHFS_COMPRESSED_BLOCK(B) (!((B) & SQUASHFS_COMPRESSED_BIT_BLOCK))
|
||||
|
||||
static inline int squashfs_block_size(__le32 raw)
|
||||
{
|
||||
u32 size = le32_to_cpu(raw);
|
||||
return (size >> 25) ? -EIO : size;
|
||||
}
|
||||
|
||||
/*
|
||||
* Inode number ops. Inodes consist of a compressed block number, and an
|
||||
* uncompressed offset within that block
|
||||
|
Reference in New Issue
Block a user