[PATCH mm-nonmm-unstable 1/2] squashfs: fix page update race

From: Vincent Whitchurch
Date: Fri May 26 2023 - 09:26:09 EST


We only put the page into the cache after we've read it, so the
PageUptodate() check should not be necessary. In fact, it's actively
harmful since the check could fail (since we used find_get_page() and
not find_lock_page()) and we could end up submitting a page for I/O
after it has been read and while it's actively being used, which could
lead to corruption depending on what the block driver does with it.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@xxxxxxxx>
---
fs/squashfs/block.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c
index 6285f5afb6c6..f2412e5fc84b 100644
--- a/fs/squashfs/block.c
+++ b/fs/squashfs/block.c
@@ -92,7 +92,7 @@ static int squashfs_bio_read_cached(struct bio *fullbio,
bio_for_each_segment_all(bv, fullbio, iter_all) {
struct page *page = bv->bv_page;

- if (page->mapping == cache_mapping && PageUptodate(page)) {
+ if (page->mapping == cache_mapping) {
idx++;
continue;
}

--
2.34.1