Skip to content

Commit 2910c59

Browse files
ploughertorvalds
authored andcommitted
squashfs: fix length field overlap check in metadata reading
This is a regression introduced by the "migrate from ll_rw_block usage to BIO" patch. Squashfs packs structures on byte boundaries, and due to that the length field (of the metadata block) may not be fully in the current block. The new code rewrote and introduced a faulty check for that edge case. Fixes: 93e72b3 ("squashfs: migrate from ll_rw_block usage to BIO") Reported-by: Bernd Amend <[email protected]> Signed-off-by: Phillip Lougher <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Adrien Schildknecht <[email protected]> Cc: Guenter Roeck <[email protected]> Cc: Daniel Rosenberg <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent e57942c commit 2910c59

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/squashfs/block.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ int squashfs_read_data(struct super_block *sb, u64 index, int length,
175175
/* Extract the length of the metadata block */
176176
data = page_address(bvec->bv_page) + bvec->bv_offset;
177177
length = data[offset];
178-
if (offset <= bvec->bv_len - 1) {
178+
if (offset < bvec->bv_len - 1) {
179179
length |= data[offset + 1] << 8;
180180
} else {
181181
if (WARN_ON_ONCE(!bio_next_segment(bio, &iter_all))) {

0 commit comments

Comments
 (0)