Forwarded: [PATCH] gfs2: fix hung task in gfs2_jhead_process_page

From: syzbot

Date: Mon Mar 23 2026 - 21:55:55 EST


For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx, syzkaller-bugs@xxxxxxxxxxxxxxxx.

***

Subject: [PATCH] gfs2: fix hung task in gfs2_jhead_process_page
Author: kartikey406@xxxxxxxxx

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master


filemap_get_folio() can return an ERR_PTR if the folio is not
present in the page cache. This can happen when a crafted or
corrupted GFS2 filesystem image is mounted and journal recovery
is triggered.

gfs2_jhead_process_page() calls filemap_get_folio() without
checking the return value, and passes the result directly to
folio_wait_locked(). When an ERR_PTR is passed to
folio_wait_locked(), the kernel task gets stuck in uninterruptible
sleep (state D) forever, triggering the hung task watchdog.

This was reported by syzbot. The reproducer mounts a crafted GFS2
image which causes gfs2_find_jhead() to call
gfs2_jhead_process_page() on a page that was never properly
submitted for I/O, causing filemap_get_folio() to return
ERR_PTR(-ENOENT).

Fix this by checking the return value of filemap_get_folio() and
marking the journal head search as done if the folio is not found,
allowing the caller to return an error gracefully.

Reported-by: syzbot+9013411dc43f3582823a@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=9013411dc43f3582823a
Signed-off-by: Deepanshu Kartikey <Kartikey406@xxxxxxxxx>
---
fs/gfs2/lops.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 797931eb5845..c2bb262318bb 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -467,6 +467,11 @@ static void gfs2_jhead_process_page(struct gfs2_jdesc *jd, unsigned long index,

folio = filemap_get_folio(jd->jd_inode->i_mapping, index);

+ if (IS_ERR(folio)) {
+ *done = true;
+ return ;
+ }
+
folio_wait_locked(folio);
if (!folio_test_uptodate(folio))
*done = true;
--
2.43.0