Skip to content

Commit 037ecab

Browse files
ploughergregkh
authored andcommitted
squashfs: fix xattr id and id lookup sanity checks
commit 8b44ca2 upstream. The checks for maximum metadata block size is missing SQUASHFS_BLOCK_OFFSET (the two byte length count). Link: https://lkml.kernel.org/r/[email protected] Fixes: f37aa4c ("squashfs: add more sanity checks in id lookup") Signed-off-by: Phillip Lougher <[email protected]> Cc: Sean Nyekjaer <[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 79b8814 commit 037ecab

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

fs/squashfs/id.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,16 @@ __le64 *squashfs_read_id_index_table(struct super_block *sb,
9797
start = le64_to_cpu(table[n]);
9898
end = le64_to_cpu(table[n + 1]);
9999

100-
if (start >= end || (end - start) > SQUASHFS_METADATA_SIZE) {
100+
if (start >= end || (end - start) >
101+
(SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) {
101102
kfree(table);
102103
return ERR_PTR(-EINVAL);
103104
}
104105
}
105106

106107
start = le64_to_cpu(table[indexes - 1]);
107-
if (start >= id_table_start || (id_table_start - start) > SQUASHFS_METADATA_SIZE) {
108+
if (start >= id_table_start || (id_table_start - start) >
109+
(SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) {
108110
kfree(table);
109111
return ERR_PTR(-EINVAL);
110112
}

fs/squashfs/xattr_id.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,16 @@ __le64 *squashfs_read_xattr_id_table(struct super_block *sb, u64 table_start,
109109
start = le64_to_cpu(table[n]);
110110
end = le64_to_cpu(table[n + 1]);
111111

112-
if (start >= end || (end - start) > SQUASHFS_METADATA_SIZE) {
112+
if (start >= end || (end - start) >
113+
(SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) {
113114
kfree(table);
114115
return ERR_PTR(-EINVAL);
115116
}
116117
}
117118

118119
start = le64_to_cpu(table[indexes - 1]);
119-
if (start >= table_start || (table_start - start) > SQUASHFS_METADATA_SIZE) {
120+
if (start >= table_start || (table_start - start) >
121+
(SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) {
120122
kfree(table);
121123
return ERR_PTR(-EINVAL);
122124
}

0 commit comments

Comments
 (0)