linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Lougher <phillip@squashfs.org.uk>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, pliard@google.com, hch@lst.de,
	adrien+dev@schischi.me, groeck@chromium.org, drosen@google.com,
	Phillip Lougher <phillip@squashfs.org.uk>,
	Bernd Amend <bernd.amend@gmail.com>
Subject: [PATCH] squashfs: fix length field overlap check in metadata reading
Date: Fri, 17 Jul 2020 20:55:36 +0100	[thread overview]
Message-ID: <20200717195536.16069-1-phillip@squashfs.org.uk> (raw)

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.

Reported-by: Bernd Amend <bernd.amend@gmail.com>
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
---
 fs/squashfs/block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c
index 64f61330564a..76bb1c846845 100644
--- a/fs/squashfs/block.c
+++ b/fs/squashfs/block.c
@@ -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))) {
-- 
2.20.1


                 reply	other threads:[~2020-07-17 20:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200717195536.16069-1-phillip@squashfs.org.uk \
    --to=phillip@squashfs.org.uk \
    --cc=adrien+dev@schischi.me \
    --cc=akpm@linux-foundation.org \
    --cc=bernd.amend@gmail.com \
    --cc=drosen@google.com \
    --cc=groeck@chromium.org \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pliard@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).