Skip to contentSkip to conversation

squashfs: fix length field overlap check in metadata reading

PATCH Applied Phillip Lougher 1 participant 1 message Jul 17, 2020 SquashFS file system

lore
Share & tools
lore

Phillip Lougher

author maintainer
#0 lore raw

PATCH 1/1 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.

---
 fs/squashfs/block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/squashfs/block.c +1 -1
index 64f61330564a..76bb1c846845 100644
@@ -175,7 +175,7 @@ int squashfs_read_data(struct super_block *sb, u64 index, int length,
 		/* Extract the length of the metadata block */
 		data = page_address(bvec->bv_page) + bvec->bv_offset;
 		length = data[offset];
-		if (offset <= bvec->bv_len - 1) {
+		if (offset < bvec->bv_len - 1) {
 			length |= data[offset + 1] << 8;
 		} else {
 			if (WARN_ON_ONCE(!bio_next_segment(bio, &iter_all))) {
Signature · 1 line
2.20.1