public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5.15.y] iomap: don't invalidate folios after writeback errors
@ 2026-03-24 11:48 driz2t
  2026-03-24 12:07 ` [v5.15] WARNING in iomap_page_release syzbot
  0 siblings, 1 reply; 2+ messages in thread
From: driz2t @ 2026-03-24 11:48 UTC (permalink / raw)
  To: syzbot+c0ffed3897231d71f047@syzkaller.appspotmail.com
  Cc: stable@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 191 bytes --]

Hi,

Please test this patch on stable 5.15.y.

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git 3330a8d33e086f76608bb4e80a3dc569d04a8814

Thanks,
Changjian Liu

[-- Attachment #2: c0ffed3897231d71f047.patch --]
[-- Type: application/octet-stream, Size: 2470 bytes --]

From e6e9ab04d37f607fe89ce5237c634ca463c11d38 Mon Sep 17 00:00:00 2001
From: Changjian Liu <driz2t@qq.com>
Date: Tue, 24 Mar 2026 19:32:14 +0800
Subject: [PATCH] iomap: don't invalidate folios after writeback errors

XFS has the unique behavior that on writeback errors it will completely
invalidate the affected folio and force the page cache to reread the
contents from disk. All other filesystems leave the page mapped and up
to date.

This is a rude awakening for user programs, since file contents will
appear to revert to old disk contents with no notification other than
an EIO on fsync. With multipage folios, we can now throw away *megabytes*
worth of data for a single write error.

Additionally, this behavior can cause a Use-After-Free (UAF) when
xfs_discard_folio invalidates multipage folios that could be undergoing
writeback. If writeback fails in the middle of a folio, we free the iop
attached to the folio, causing writeback completion on the earlier part
to trip over assertions.

Get rid of the whole behavior entirely by returning early in
xfs_discard_folio() if the filesystem is shutting down, and removing
the unconditional folio_clear_uptodate() call in iomap_writepage_map().

Signed-off-by: Changjian Liu <driz2t@qq.com>
---
 fs/iomap/buffered-io.c | 1 -
 fs/xfs/xfs_aops.c      | 4 +---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 87a4f5a2ded0..1f0bfe0b8bae 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -1350,7 +1350,6 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
 		if (wpc->ops->discard_page)
 			wpc->ops->discard_page(page, file_offset);
 		if (!count) {
-			ClearPageUptodate(page);
 			unlock_page(page);
 			goto done;
 		}
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index c8c15c3c3147..56a5bd7ad8c4 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -450,7 +450,7 @@ xfs_discard_page(
 	int			error;
 
 	if (xfs_is_shutdown(mp))
-		goto out_invalidate;
+		return;
 
 	xfs_alert_ratelimited(mp,
 		"page discard on page "PTR_FMT", inode 0x%llx, offset %llu.",
@@ -460,8 +460,6 @@ xfs_discard_page(
 			i_blocks_per_page(inode, page) - pageoff_fsb);
 	if (error && !xfs_is_shutdown(mp))
 		xfs_alert(mp, "page discard unable to remove delalloc mapping.");
-out_invalidate:
-	iomap_invalidatepage(page, pageoff, PAGE_SIZE - pageoff);
 }
 
 static const struct iomap_writeback_ops xfs_writeback_ops = {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [v5.15] WARNING in iomap_page_release
  2026-03-24 11:48 [PATCH 5.15.y] iomap: don't invalidate folios after writeback errors driz2t
@ 2026-03-24 12:07 ` syzbot
  0 siblings, 0 replies; 2+ messages in thread
From: syzbot @ 2026-03-24 12:07 UTC (permalink / raw)
  To: driz2t, stable, syzkaller-lts-bugs

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+c0ffed3897231d71f047@syzkaller.appspotmail.com
Tested-by: syzbot+c0ffed3897231d71f047@syzkaller.appspotmail.com

Tested on:

commit:         3330a8d3 Linux 5.15.201
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=16f95372580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=30e28339904629ca
dashboard link: https://syzkaller.appspot.com/bug?extid=c0ffed3897231d71f047
compiler:       Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
patch:          https://syzkaller.appspot.com/x/patch.diff?x=15b4506a580000

Note: testing is done by a robot and is best-effort only.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-24 12:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24 11:48 [PATCH 5.15.y] iomap: don't invalidate folios after writeback errors driz2t
2026-03-24 12:07 ` [v5.15] WARNING in iomap_page_release syzbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox