Skip to contentSkip to conversation

squashfs-check-block-offset-is-not-negative.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Aug 13

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: Squashfs: check block offset is not negative
has been removed from the -mm tree. Its filename was
squashfs-check-block-offset-is-not-negative.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Phillip Lougher <[email protected]>
Subject: Squashfs: check block offset is not negative
Date: Fri, 7 Aug 2026 17:29:51 +0100

If a negative offset is read off disk (for example the offset into the decompressed fragment block), this will cause squashfs_copy_data() to perform an out of bounds access.

Fix by checking if offset is negative, and returning 0. This matches existing behaviour where an offset beyond the block returns 0 bytes copied.

To trigger this out of bounds access requires a crafted Squashfs filesystem and CAP_SYS_ADMIN to mount it. Unprivileged users will not be able to mount such a filesystem, but once mounted, an unprivileged user can trigger the out of bounds access by reading the crafted file with the negative offset.

---

 fs/squashfs/cache.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/squashfs/cache.c renamed from fs/squashfs/cache.c~squashfs-check-block-offset-is-not-negative +1 -1
@@ -299,7 +299,7 @@ int squashfs_copy_data(void *buffer, str
 {
 	int remaining = length;
 
-	if (length == 0)
+	if (length == 0 || offset < 0)
 		return 0;
 	else if (buffer == NULL)
 		return min(length, entry->length - offset);

_

Patches currently in -mm which might be from [email protected] are

maintainers-remove-git-url-for-squashfs.patch