]> git.baikalelectronics.ru Git - kernel.git/commitdiff
squashfs: fix length field overlap check in metadata reading
authorPhillip Lougher <phillip@squashfs.org.uk>
Fri, 24 Jul 2020 04:15:40 +0000 (21:15 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 24 Jul 2020 19:42:41 +0000 (12:42 -0700)
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: 6e5379b39086d4beda ("squashfs: migrate from ll_rw_block usage to BIO")
Reported-by: Bernd Amend <bernd.amend@gmail.com>
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Adrien Schildknecht <adrien+dev@schischi.me>
Cc: Guenter Roeck <groeck@chromium.org>
Cc: Daniel Rosenberg <drosen@google.com>
Link: http://lkml.kernel.org/r/20200717195536.16069-1-phillip@squashfs.org.uk
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/squashfs/block.c

index 64f61330564acdb9b38995cfb8f02f2c040435e7..76bb1c846845e33737d428dcc26e4840fd4aeebe 100644 (file)
@@ -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))) {