Skip to contentSkip to conversation

squashfs-fix-extending-readahead-beyond-end-of-file.patch removed from -mm tree

merged mm-hotfixes-stable Andrew Morton 1 participant 1 message Oct 28, 2022 Stable branch

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: squashfs: fix extending readahead beyond end of file
has been removed from the -mm tree. Its filename was
squashfs-fix-extending-readahead-beyond-end-of-file.patch

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

------------------------------------------------------
From: Phillip Lougher <[email protected]>
Subject: squashfs: fix extending readahead beyond end of file
Date: Thu, 20 Oct 2022 23:36:15 +0100

The readahead code will try to extend readahead to the entire size of the Squashfs data block.

But, it didn't take into account that the last block at the end of the file may not be a whole block. In this case, the code would extend readahead to beyond the end of the file, leaving trailing pages.

Fix this by only requesting the expected number of pages.

Fixes 8fc78b6fe24c ("squashfs: implement readahead")
Cc Dimitri John Ledkov <[email protected]>
Cc Hsin-Yi Wang <[email protected]>
Cc Mirsad Goran Todorovac <[email protected]>
Cc Slade Watkins <[email protected]>
Cc Thorsten Leemhuis <[email protected]>

---

fs/squashfs/file.c renamed from fs/squashfs/file.c~squashfs-fix-extending-readahead-beyond-end-of-file +7 -4
@@ -559,6 +559,12 @@ static void squashfs_readahead(struct re
 		unsigned int expected;
 		struct page *last_page;
 
+		expected = start >> msblk->block_log == file_end ?
+			   (i_size_read(inode) & (msblk->block_size - 1)) :
+			    msblk->block_size;
+
+		max_pages = (expected + PAGE_SIZE - 1) >> PAGE_SHIFT;
+
 		nr_pages = __readahead_batch(ractl, pages, max_pages);
 		if (!nr_pages)
 			break;
@@ -567,13 +573,10 @@ static void squashfs_readahead(struct re
 			goto skip_pages;
 
 		index = pages[0]->index >> shift;
+
 		if ((pages[nr_pages - 1]->index >> shift) != index)
 			goto skip_pages;
 
-		expected = index == file_end ?
-			   (i_size_read(inode) & (msblk->block_size - 1)) :
-			    msblk->block_size;
-
 		if (index == file_end && squashfs_i(inode)->fragment_block !=
 						SQUASHFS_INVALID_BLK) {
 			res = squashfs_readahead_fragment(pages, nr_pages,

_

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