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>,
	Michael Olbrich <mol@pengutronix.de>,
	Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 6/6] squashfs: refuse mount of squashfs images with non-128K block size
Date: Wed, 17 Jul 2024 08:33:28 +0200	[thread overview]
Message-ID: <20240717063328.2810835-7-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240717063328.2810835-1-a.fatoum@pengutronix.de>

Mounting a block of any size, but 128K, leads to erroneous data in blocks
beyond the first. It would be nice to support the full-range of block
sizes supported by Linux, but for now, let's just enforce that the
default block size of 128K is used and refuse the mount with an error
message if the image has been generated with a non-default block size.

Reported-by: Michael Olbrich <mol@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 fs/squashfs/Kconfig | 5 +----
 fs/squashfs/super.c | 7 +++++++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/squashfs/Kconfig b/fs/squashfs/Kconfig
index af187a2a8ac7..c57ef0044cdd 100644
--- a/fs/squashfs/Kconfig
+++ b/fs/squashfs/Kconfig
@@ -9,10 +9,7 @@ menuconfig FS_SQUASHFS
 	  filesystem for Linux.  It uses zlib, lzo or xz compression to
 	  compress both files, inodes and directories.  Inodes in the system
 	  are very small and all blocks are packed to minimise data overhead.
-	  Block sizes greater than 4K are supported up to a maximum of 1 Mbytes
-	  (default block size 128K).  SquashFS 4.0 supports 64 bit filesystems
-	  and files (larger than 4GB), full uid/gid information, hard links and
-	  timestamps.
+	  Only the default block sizes of 128K is supported.
 
 	  Squashfs is intended for general read-only filesystem use, for
 	  archival use (i.e. in cases where a .tar.gz file may be used), and in
diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c
index f3dac6de1527..7695c9e0fd25 100644
--- a/fs/squashfs/super.c
+++ b/fs/squashfs/super.c
@@ -31,6 +31,7 @@
 #include <linux/pagemap.h>
 #include <linux/magic.h>
 #include <linux/bitops.h>
+#include <linux/sizes.h>
 
 #include "page_actor.h"
 #include "squashfs_fs.h"
@@ -172,6 +173,12 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent)
 		goto failed_mount;
 	}
 
+	if (msblk->block_size != SZ_128K) {
+		ERROR("filesystem block size (%d) != 128K.  This is "
+			"currently not supported!\n", msblk->block_size);
+		goto failed_mount;
+	}
+
 	/* Check block log for sanity */
 	msblk->block_log = le16_to_cpu(sblk->block_log);
 	if (msblk->block_log > SQUASHFS_FILE_MAX_LOG)
-- 
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 ` [PATCH 2/6] squashfs: more metadata hardening Ahmad Fatoum
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 ` Ahmad Fatoum [this message]
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-7-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=mol@pengutronix.de \
    --cc=richard@nod.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