Skip to contentSkip to conversation

erofs: fix "BUG: Bad page state in z_erofs_do_read_page"

PATCH Applied Gao Xiang 2 participants 2 messages Mar 27 – Mar 31

Subsystems (2)
lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs: fix "BUG: Bad page state in z_erofs_do_read_page"

It's actually a stable-only issue from backporting 9e2f9d34dd12 ("erofs: handle overlapped pclusters out of crafted images properly")

We missed to update oldpage after pcl->compressed_bvecs[nr].page is updated, so that the following cmpxchg() will fail; the original upstream commit doesn't behave like this due to new features and refactoring.

This backport issue only impacts some specific crafted images and normal filesystems won't be impacted at all.

Fixes 1bf7e414cac3 ("erofs: handle overlapped pclusters out of crafted images properly") # 6.6.y
Reported-and-tested-by [email protected] [1]

[1] https://lore.kernel.org/r/[email protected]

---
 fs/erofs/zdata.c | 1 +
 1 file changed, 1 insertion(+)
fs/erofs/zdata.c +1 -0
index c1f802ecc47b..97764612fc76 100644
@@ -1500,6 +1500,7 @@ static struct page *pickup_page_for_submission(struct z_erofs_pcluster *pcl,
 	lock_page(page);
 	if (likely(page->mapping == mc)) {
 		WRITE_ONCE(pcl->compressed_bvecs[nr].page, page);
+		oldpage = page;
 
 		/*
 		 * The cached folio is still in managed cache but without
Signature · 1 line
2.43.5
maintainer Applied
#1 lore raw

Patch "erofs: fix "BUG: Bad page state in z_erofs_do_read_page"" has been added to the 6.6-stable tree

This is a note to let you know that I've just added the patch titled

erofs: fix "BUG: Bad page state in z_erofs_do_read_page"

to the 6.6-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
erofs-fix-bug-bad-page-state-in-z_erofs_do_read_page.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From [email protected] Fri Mar 27 05:15:33 2026
From: Gao Xiang <[email protected]>
Date: Fri, 27 Mar 2026 12:15:24 +0800
Subject: erofs: fix "BUG: Bad page state in z_erofs_do_read_page"
To: [email protected], Greg Kroah-Hartman <[email protected]>
Cc: [email protected], Gao Xiang <[email protected]>, [email protected]
Message-ID: <[email protected]>

From: Gao Xiang <[email protected]>

It's actually a stable-only issue from backporting 9e2f9d34dd12 ("erofs: handle overlapped pclusters out of crafted images properly")

We missed to update oldpage after pcl->compressed_bvecs[nr].page is updated, so that the following cmpxchg() will fail; the original upstream commit doesn't behave like this due to new features and refactoring.

This backport issue only impacts some specific crafted images and normal filesystems won't be impacted at all.

Fixes 1bf7e414cac3 ("erofs: handle overlapped pclusters out of crafted images properly") # 6.6.y
Reported-and-tested-by [email protected] [1]

[1] https://lore.kernel.org/r/[email protected]

---
 fs/erofs/zdata.c |    1 +
 1 file changed, 1 insertion(+)
fs/erofs/zdata.c +1 -0
@@ -1503,6 +1503,7 @@ repeat:
 	lock_page(page);
 	if (likely(page->mapping == mc)) {
 		WRITE_ONCE(pcl->compressed_bvecs[nr].page, page);
+		oldpage = page;
 
 		/*
 		 * The cached folio is still in managed cache but without

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

queue-6.6/erofs-add-gfp_noio-in-the-bio-completion-if-needed.patch queue-6.6/erofs-fix-bug-bad-page-state-in-z_erofs_do_read_page.patch