mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Richard Weinberger <richard@nod.at>,
	Richard Weinberger <richard@sigma-star.at>,
	Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/6] squashfs: more metadata hardening
Date: Wed, 17 Jul 2024 08:33:24 +0200	[thread overview]
Message-ID: <20240717063328.2810835-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240717063328.2810835-1-a.fatoum@pengutronix.de>

This is a port of Linux commit d512584780d3e6a7cacb2f482834849453d444a1:

| Author:     Linus Torvalds <torvalds@linux-foundation.org>
| AuthorDate: Mon Jul 30 14:27:15 2018 -0700
|
| Anatoly reports another squashfs fuzzing issue, where the decompression
| parameters themselves are in a compressed block.
|
| This causes squashfs_read_data() to be called in order to read the
| decompression options before the decompression stream having been set
| up, making squashfs go sideways.
|
| Reported-by: Anatoly Trosinenko <anatoly.trosinenko@gmail.com>
| Acked-by: Phillip Lougher <phillip.lougher@gmail.com>
| Cc: stable@kernel.org
| Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Reported-by: Richard Weinberger <richard@sigma-star.at>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 fs/squashfs/block.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c
index 3e2b9a5ebda8..d65035cead54 100644
--- a/fs/squashfs/block.c
+++ b/fs/squashfs/block.c
@@ -164,6 +164,8 @@ int squashfs_read_data(struct super_block *sb, u64 index, int length,
 	}
 
 	if (compressed) {
+		if (!msblk->stream)
+			goto read_failure;
 		length = squashfs_decompress(msblk, buf, b, offset, length,
 			output);
 		if (length < 0)
-- 
2.39.2




  parent reply	other threads:[~2024-07-17  6:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-17  6:33 [PATCH 0/6] squashfs: harden against crafted metadata Ahmad Fatoum
2024-07-17  6:33 ` [PATCH 1/6] squashfs: be more careful about metadata corruption Ahmad Fatoum
2024-07-17  6:33 ` Ahmad Fatoum [this message]
2024-07-17  6:33 ` [PATCH 3/6] squashfs metadata 2: electric boogaloo Ahmad Fatoum
2024-07-17  6:33 ` [PATCH 4/6] squashfs: more metadata hardening Ahmad Fatoum
2024-07-17  6:33 ` [PATCH 5/6] Squashfs: Compute expected length from inode size rather than block length Ahmad Fatoum
2024-07-17  6:33 ` [PATCH 6/6] squashfs: refuse mount of squashfs images with non-128K block size Ahmad Fatoum
2024-07-19  6:36 ` [PATCH 0/6] squashfs: harden against crafted metadata Sascha Hauer

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=20240717063328.2810835-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=richard@sigma-star.at \
    /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