Skip to content

Commit 79b8814

Browse files
sknseangregkh
authored andcommitted
squashfs: fix inode lookup sanity checks
commit c1b2028 upstream. When mouting a squashfs image created without inode compression it fails with: "unable to read inode lookup table" It turns out that the BLOCK_OFFSET is missing when checking the SQUASHFS_METADATA_SIZE agaist the actual size. Link: https://lkml.kernel.org/r/[email protected] Fixes: eabac19 ("squashfs: add more sanity checks in inode lookup") Signed-off-by: Sean Nyekjaer <[email protected]> Acked-by: Phillip Lougher <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5b1abfe commit 79b8814

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

fs/squashfs/export.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,18 @@ __le64 *squashfs_read_inode_lookup_table(struct super_block *sb,
152152
start = le64_to_cpu(table[n]);
153153
end = le64_to_cpu(table[n + 1]);
154154

155-
if (start >= end || (end - start) > SQUASHFS_METADATA_SIZE) {
155+
if (start >= end
156+
|| (end - start) >
157+
(SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) {
156158
kfree(table);
157159
return ERR_PTR(-EINVAL);
158160
}
159161
}
160162

161163
start = le64_to_cpu(table[indexes - 1]);
162-
if (start >= lookup_table_start || (lookup_table_start - start) > SQUASHFS_METADATA_SIZE) {
164+
if (start >= lookup_table_start ||
165+
(lookup_table_start - start) >
166+
(SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) {
163167
kfree(table);
164168
return ERR_PTR(-EINVAL);
165169
}

fs/squashfs/squashfs_fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
/* size of metadata (inode and directory) blocks */
1919
#define SQUASHFS_METADATA_SIZE 8192
20+
#define SQUASHFS_BLOCK_OFFSET 2
2021

2122
/* default size of block device I/O */
2223
#ifdef CONFIG_SQUASHFS_4K_DEVBLK_SIZE

0 commit comments

Comments
 (0)