linux/fs/squashfs
Phillip Lougher 9ef8eb6104 squashfs: fix read regression introduced in readahead code
Patch series "squashfs: fix some regressions introduced in the readahead
code".

This patchset fixes 3 regressions introduced by the recent readahead code
changes.  The first regression is causing "snaps" to randomly fail after a
couple of hours or days, which how the regression came to light.


This patch (of 3):

If a file isn't a whole multiple of the page size, the last page will have
trailing bytes unfilled.

There was a mistake in the readahead code which did this.  In particular
it incorrectly assumed that the last page in the readahead page array
(page[nr_pages - 1]) will always contain the last page in the block, which
if we're at file end, will be the page that needs to be zero filled.

But the readahead code may not return the last page in the block, which
means it is unmapped and will be skipped by the decompressors (a temporary
buffer used).

In this case the zero filling code will zero out the wrong page, leading
to data corruption.

Fix this by by extending the "page actor" to return the last page if
present, or NULL if a temporary buffer was used.

Link: https://lkml.kernel.org/r/20221020223616.7571-1-phillip@squashfs.org.uk
Link: https://lkml.kernel.org/r/20221020223616.7571-2-phillip@squashfs.org.uk
Fixes: 8fc78b6fe2 ("squashfs: implement readahead")
Link: https://lore.kernel.org/lkml/b0c258c3-6dcf-aade-efc4-d62a8b3a1ce2@alu.unizg.hr/
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
Reported-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Tested-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Tested-by: Slade Watkins <srw@sladewatkins.net>
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: Thorsten Leemhuis <regressions@leemhuis.info>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2022-10-28 13:37:21 -07:00
..
block.c squashfs: extend "page actor" to handle missing pages 2022-06-16 19:58:21 -07:00
cache.c
decompressor_multi_percpu.c
decompressor_multi.c
decompressor_single.c
decompressor.c
decompressor.h squashfs: extend "page actor" to handle missing pages 2022-06-16 19:58:21 -07:00
dir.c
export.c squashfs: fix inode lookup sanity checks 2021-03-25 09:22:55 -07:00
file_cache.c
file_direct.c squashfs: don't call kmalloc in decompressors 2022-08-28 14:02:45 -07:00
file.c squashfs: fix read regression introduced in readahead code 2022-10-28 13:37:21 -07:00
fragment.c
id.c squashfs: fix xattr id and id lookup sanity checks 2021-03-25 09:22:55 -07:00
inode.c
Kconfig
lz4_wrapper.c squashfs: extend "page actor" to handle missing pages 2022-06-16 19:58:21 -07:00
lzo_wrapper.c squashfs: extend "page actor" to handle missing pages 2022-06-16 19:58:21 -07:00
Makefile squashfs: always build "file direct" version of page actor 2022-07-29 18:12:34 -07:00
namei.c
page_actor.c squashfs: fix read regression introduced in readahead code 2022-10-28 13:37:21 -07:00
page_actor.h squashfs: fix read regression introduced in readahead code 2022-10-28 13:37:21 -07:00
squashfs_fs_i.h
squashfs_fs_sb.h squashfs: add option to panic on errors 2021-06-29 10:53:46 -07:00
squashfs_fs.h squashfs: fix inode lookup sanity checks 2021-03-25 09:22:55 -07:00
squashfs.h
super.c Revert "squashfs: provide backing_dev_info in order to disable read-ahead" 2022-07-29 18:12:34 -07:00
symlink.c squashfs: Convert squashfs to read_folio 2022-05-09 16:21:46 -04:00
xattr_id.c squashfs: fix xattr id and id lookup sanity checks 2021-03-25 09:22:55 -07:00
xattr.c
xattr.h
xz_wrapper.c squashfs: extend "page actor" to handle missing pages 2022-06-16 19:58:21 -07:00
zlib_wrapper.c squashfs: extend "page actor" to handle missing pages 2022-06-16 19:58:21 -07:00
zstd_wrapper.c squashfs: extend "page actor" to handle missing pages 2022-06-16 19:58:21 -07:00