From: Andrew Morton <akpm@linux-foundation.org>
To: Phillip Lougher <phillip@squashfs.org.uk>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Christian Loehle <christian.loehle@arm.com>
Subject: Re: [PATCH v2 17/22] Squashfs: don't store large export table indexes in memory
Date: Thu, 12 Nov 2026 11:09:27 -0800 [thread overview]
Message-ID: <20261112110927.6add17b0552922c5b6b93515@linux-foundation.org> (raw)
In-Reply-To: <20261111234402.252354-18-phillip@squashfs.org.uk>
On Wed, 11 Nov 2026 23:43:57 +0000 Phillip Lougher <phillip@squashfs.org.uk> wrote:
> When mounting a Squashfs filesystem, the code reads the entire
> export table indexes into memory. Their size is determined by the
> number of inodes in the filesystem. For the maximum inode
> count of 2^32, this will allocate and read 32 MiB.
>
> This is an excessive and unnecessary amount of memory because the
> indexes do not need to be read into memory in their entirety. In
> addition kmalloc() is used to allocate memory, and this can fail when
> large amounts of memory are requested. Kmalloc() on modern kernels is
> usually limited to 4096 KiB. If panic-on-warn is set, then failure to
> allocate memory will result in a kernel panic.
>
> This commit uses a 4 page cache if the size of the export table indexes
> are 4 pages in size or larger. A simple and fast lookup array is
> retained where the total index size is less than 4 pages in size, which
> is the vast majority of Squashfs filesystems.
Thanks. This patch didn't anticipate the presence of Christian's
"squashfs: identify device in mount errors". To make life easier I've
staged Christian's patch behind this 22-patch series.
This required a bit of rework of Christian's patch. While in there I
filled in a few more places which needed Christian's treatment and I
made the whole thing more 80-column friendly where that made sense.
Please check:
From: Christian Loehle <christian.loehle@arm.com>
Subject: squashfs: identify device in mount errors
Date: Sat, 12 Sep 2026 15:53:14 +0100
Squashfs mount failures reported through fs_context do not identify the
backing device, fix this by printing the block device.
Repeated automount failures used to be ambiguous, for example:
Filesystem uses "xz" compression. This is not supported
All of the affected errors occur after get_tree_bdev() has opened the
block device and setup_bdev_super() has assigned sb->s_bdev. Use it to
identify the failing Squashfs image even when the mount is retried. For
example, the error above now reads:
Filesystem on loop0 uses "xz" compression. This is not supported
Link: https://lore.kernel.org/20260912145314.788588-1-christian.loehle@arm.com
Signed-off-by: Christian Loehle <christian.loehle@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Phillip Lougher <phillip@squashfs.org.uk>
---
fs/squashfs/super.c | 48 ++++++++++++++++++++++++------------------
1 file changed, 28 insertions(+), 20 deletions(-)
--- a/fs/squashfs/super.c~squashfs-identify-device-in-mount-errors
+++ a/fs/squashfs/super.c
@@ -151,26 +151,26 @@ static int squashfs_parse_param(struct f
}
static const struct squashfs_decompressor *supported_squashfs_filesystem(
- struct fs_context *fc,
+ struct super_block *sb, struct fs_context *fc,
short major, short minor, short id)
{
const struct squashfs_decompressor *decompressor;
if (major < SQUASHFS_MAJOR) {
- errorf(fc, "Major/Minor mismatch, older Squashfs %d.%d "
- "filesystems are unsupported", major, minor);
+ errorf(fc, "Unsupported older Squashfs %d.%d filesystem on %pg",
+ major, minor, sb->s_bdev);
return NULL;
} else if (major > SQUASHFS_MAJOR || minor > SQUASHFS_MINOR) {
- errorf(fc, "Major/Minor mismatch, trying to mount newer "
- "%d.%d filesystem", major, minor);
+ errorf(fc, "Major/Minor mismatch, trying to mount newer %d.%d filesystem on %pg",
+ major, minor, sb->s_bdev);
errorf(fc, "Please update your kernel");
return NULL;
}
decompressor = squashfs_lookup_decompressor(id);
if (!decompressor->supported) {
- errorf(fc, "Filesystem uses \"%s\" compression. This is not supported",
- decompressor->name);
+ errorf(fc, "Filesystem on %pg uses \"%s\" compression. This is not supported",
+ sb->s_bdev, decompressor->name);
return NULL;
}
@@ -217,7 +217,8 @@ static int squashfs_fill_super(struct su
TRACE("Entered squashfs_fill_superblock\n");
if (!devblksize) {
- errorf(fc, "squashfs: unable to set blocksize\n");
+ errorf(fc, "squashfs: unable to set blocksize on %pg\n",
+ sb->s_bdev);
return -EINVAL;
}
@@ -246,7 +247,8 @@ static int squashfs_fill_super(struct su
sblk = squashfs_read_table(sb, SQUASHFS_START, sizeof(*sblk));
if (IS_ERR(sblk)) {
- errorf(fc, "unable to read squashfs_super_block");
+ errorf(fc, "unable to read squashfs_super_block on %pg",
+ sb->s_bdev);
err = PTR_ERR(sblk);
sblk = NULL;
goto failed_mount;
@@ -271,7 +273,7 @@ static int squashfs_fill_super(struct su
/* Check the MAJOR & MINOR versions and lookup compression type */
msblk->decompressor = supported_squashfs_filesystem(
- fc,
+ sb, fc,
le16_to_cpu(sblk->s_major),
le16_to_cpu(sblk->s_minor),
le16_to_cpu(sblk->compression));
@@ -295,8 +297,8 @@ static int squashfs_fill_super(struct su
* block size (by default 128K). This is currently not supported.
*/
if (PAGE_SIZE > msblk->block_size) {
- errorf(fc, "Page size > filesystem block size (%d). This is "
- "currently not supported!", msblk->block_size);
+ errorf(fc, "Page size > filesystem block size (%d) on %pg is not supported",
+ msblk->block_size, sb->s_bdev);
goto failed_mount;
}
@@ -355,7 +357,8 @@ static int squashfs_fill_super(struct su
msblk->read_page = squashfs_cache_init("data",
SQUASHFS_READ_PAGES, msblk->block_size);
if (IS_ERR(msblk->read_page)) {
- errorf(fc, "Failed to allocate read_page block");
+ errorf(fc, "Failed to allocate read_page block for %pg",
+ sb->s_bdev);
err = PTR_ERR(msblk->read_page);
goto failed_mount;
}
@@ -394,7 +397,8 @@ static int squashfs_fill_super(struct su
err = squashfs_read_xattr_id_table(sb, msblk->xattr_id_table,
&msblk->xattr_table, &msblk->xattr_ids);
if (err < 0) {
- errorf(fc, "unable to read xattr id index table");
+ errorf(fc, "unable to read xattr id index table on %pg",
+ sb->s_bdev);
if (err != -ENOTSUPP)
goto failed_mount;
}
@@ -405,7 +409,7 @@ allocate_id_index_table:
msblk->id_table = squashfs_read_id_index_table(sb,
le64_to_cpu(sblk->id_table_start), next_table, msblk->ids);
if (IS_ERR(msblk->id_table)) {
- errorf(fc, "unable to read id index table");
+ errorf(fc, "unable to read id index table on %pg", sb->s_bdev);
err = PTR_ERR(msblk->id_table);
msblk->id_table = NULL;
goto failed_mount;
@@ -421,13 +425,15 @@ allocate_id_index_table:
err = squashfs_read_inode_lookup_table(sb, msblk->lookup_table,
next_table, msblk->inodes);
if (err < 0) {
- errorf(fc, "unable to read inode lookup table");
+ errorf(fc, "unable to read inode lookup table on %pg",
+ sb->s_bdev);
goto failed_mount;
}
err = squashfs_inode_lookup_start(sb, 1);
if (err < 0) {
- errorf(fc, "unable to read inode lookup table");
+ errorf(fc, "unable to read inode lookup table on %pg",
+ sb->s_bdev);
goto failed_mount;
}
next_table = msblk->lookup_table_start = err;
@@ -450,13 +456,15 @@ handle_fragments:
err = squashfs_read_fragment_index_table(sb, msblk->fragment_table,
next_table, fragments);
if (err < 0) {
- errorf(fc, "unable to read fragment index table");
+ errorf(fc, "unable to read fragment index table on %pg",
+ sb->s_bdev);
goto failed_mount;
}
err = squashfs_frag_lookup_start(sb, 0);
if (err < 0) {
- errorf(fc, "unable to read fragment index table");
+ errorf(fc, "unable to read fragment index table on %pg",
+ sb->s_bdev);
goto failed_mount;
}
next_table = msblk->fragment_table_start = err;
@@ -502,7 +510,7 @@ check_directory_table:
return 0;
insanity:
- errorf(fc, "squashfs image failed sanity check");
+ errorf(fc, "squashfs image on %pg failed sanity check", sb->s_bdev);
failed_mount:
squashfs_cache_delete(msblk->block_cache);
squashfs_cache_delete(msblk->fragment_cache);
_
next prev parent reply other threads:[~2026-11-12 19:09 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 23:43 [PATCH v2 00/22] Squashfs: fix a lot of AI issues and AI style issues Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 01/22] Squashfs: convert SQUASHFS_COMPRESSED_* to inline functions Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 02/22] Squashfs: convert SQUASHFS_INODE_* and SQUASHFS_MKINODE " Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 03/22] Squashfs: convert SQUASHFS_FRAGMENT_* " Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 04/22] Squashfs: convert SQUASHFS_LOOKUP_* " Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 05/22] Squashfs: convert SQUASHFS_ID_* " Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 06/22] Squashfs: convert SQUASHFS_XATTR_* " Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 07/22] Squashfs: fix offset in squashfs_read_inode() TRACE statements Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 08/22] Squashfs: fix fragment bytes overflow on 32-bit architectures Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 09/22] Squashfs: fix fragment index table length too large exploit Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 10/22] Squashfs: sanity check inode metadata block location Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 11/22] Squashfs: sanity check directory " Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 12/22] Squashfs: widen xattr count variables and add sanity check Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 13/22] Squashfs: very large files can exceed an int block count Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 14/22] Squashfs: add more sanity checking to squashfs_block_size() Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 15/22] Squashfs: sanity check fragment block location and range Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 16/22] Squashfs: sanity check block list sizes " Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 17/22] Squashfs: don't store large export table indexes in memory Phillip Lougher
2026-11-12 19:09 ` Andrew Morton [this message]
2026-11-11 23:43 ` [PATCH v2 18/22] Squashfs: don't store large fragment " Phillip Lougher
2026-11-11 23:43 ` [PATCH v2 19/22] Squashfs: don't store large xattr id " Phillip Lougher
2026-11-11 23:44 ` [PATCH v2 20/22] Squashfs: fix variables in directory code and add more sanity checks Phillip Lougher
2026-11-11 23:44 ` [PATCH v2 21/22] Squashfs: fix regression in squashfs_copy_cache() Phillip Lougher
2026-11-11 23:44 ` [PATCH v2 22/22] Squashfs: check index isn't greater than S64_MAX in squashfs_read_data() Phillip Lougher
2026-11-16 6:49 ` [syzbot ci] Re: Squashfs: fix a lot of AI issues and AI style issues syzbot ci
2026-11-16 7:28 ` Andrew Morton
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=20261112110927.6add17b0552922c5b6b93515@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=christian.loehle@arm.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=phillip@squashfs.org.uk \
/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
all inboxes | Powered by JetHome®