squashfs: fix extending readahead beyond end of file
authorPhillip Lougher <phillip@squashfs.org.uk>
Thu, 20 Oct 2022 22:36:15 +0000 (23:36 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 28 Oct 2022 20:37:21 +0000 (13:37 -0700)
commitc9199de82bad03bceb94ec3c5195c879d7e11911
tree5da390ab71954d51685deb503d9d75fc2ab8d11e
parent9ef8eb6104527bfe9ed31f7a4ffa721390adf9a8
squashfs: fix extending readahead beyond end of file

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.

Link: https://lkml.kernel.org/r/20221020223616.7571-3-phillip@squashfs.org.uk
Fixes: 8fc78b6fe24c ("squashfs: implement readahead")
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>
Reported-by: Marc Miltenberger <marcmiltenberger@gmail.com>
Cc: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
Cc: Hsin-Yi Wang <hsinyi@chromium.org>
Cc: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Cc: Slade Watkins <srw@sladewatkins.net>
Cc: Thorsten Leemhuis <regressions@leemhuis.info>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/squashfs/file.c