mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Phillip Lougher <phillip@squashfs.org.uk>
To: akpm@linux-foundation.org, linux-kernel@vger.kernel.org
Cc: Phillip Lougher <phillip@squashfs.org.uk>
Subject: [PATCH v3 23/23] Squashfs: check index isn't greater than S64_MAX in squashfs_read_data()
Date: Mon, 23 Nov 2026 03:43:04 +0000	[thread overview]
Message-ID: <20261123034304.261742-24-phillip@squashfs.org.uk> (raw)
In-Reply-To: <20261123034304.261742-1-phillip@squashfs.org.uk>

The previous commits in this patch-set now sanity check index before
squashfs_read_data() is called.  However, it is always wise to take
a belts and braces approach and sanity check at the lowest level to
trap any values that could slip through.

Fixes: e2780ab159ac6 ("Squashfs: block operations")
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
---
 fs/squashfs/block.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c
index 20c3030b4f96..f2f03d815167 100644
--- a/fs/squashfs/block.c
+++ b/fs/squashfs/block.c
@@ -297,6 +297,15 @@ int squashfs_read_data(struct super_block *sb, u64 index, int length,
 	int res;
 	int offset;
 
+	/*
+	 * Reject index values greater than possible filesystem size (S64_MAX).
+	 * This also ensures the index variable doesn't overflow in the function.
+	 */
+	if (index > S64_MAX) {
+		res = -EIO;
+		goto out;
+	}
+
 	if (length) {
 		/*
 		 * Datablock.
-- 
2.47.3


  parent reply	other threads:[~2026-11-23  3:44 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  3:42 [PATCH v3 00/23] Squashfs: fix a lot of AI issues and AI style issues Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 01/23] Squashfs: convert SQUASHFS_COMPRESSED_* to inline functions Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 02/23] Squashfs: convert SQUASHFS_INODE_* and SQUASHFS_MKINODE " Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 03/23] Squashfs: convert SQUASHFS_FRAGMENT_* " Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 04/23] Squashfs: convert SQUASHFS_LOOKUP_* " Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 05/23] Squashfs: convert SQUASHFS_ID_* " Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 06/23] Squashfs: convert SQUASHFS_XATTR_* " Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 07/23] Squashfs: fix offset in squashfs_read_inode() TRACE statements Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 08/23] Squashfs: don't compute start or alloc memory on empty directory or index Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 09/23] Squashfs: fix fragment bytes overflow on 32-bit architectures Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 10/23] Squashfs: fix fragment index table length too large exploit Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 11/23] Squashfs: sanity check inode metadata block location Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 12/23] Squashfs: sanity check directory " Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 13/23] Squashfs: widen xattr count variables and add sanity check Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 14/23] Squashfs: very large files can exceed an int or size_t Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 15/23] Squashfs: add more sanity checking to squashfs_block_size() Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 16/23] Squashfs: sanity check fragment block location and range Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 17/23] Squashfs: sanity check block list sizes " Phillip Lougher
2026-11-23  3:42 ` [PATCH v3 18/23] Squashfs: don't store large export table indexes in memory Phillip Lougher
2026-11-23  3:43 ` [PATCH v3 19/23] Squashfs: don't store large fragment " Phillip Lougher
2026-11-23  3:43 ` [PATCH v3 20/23] Squashfs: don't store large xattr id " Phillip Lougher
2026-11-23  3:43 ` [PATCH v3 21/23] Squashfs: fix variables in directory code and add more sanity checks Phillip Lougher
2026-11-23  3:43 ` [PATCH v3 22/23] Squashfs: fix regression in squashfs_copy_cache() Phillip Lougher
2026-11-23  3:43 ` Phillip Lougher [this message]
2026-11-23  4:13 ` [PATCH v3 00/23] Squashfs: fix a lot of AI issues and AI style issues 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=20261123034304.261742-24-phillip@squashfs.org.uk \
    --to=phillip@squashfs.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /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®