]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
nilfs2: fix kernel bug due to missing clearing of checked flag
authorRyusuke Konishi <konishi.ryusuke@gmail.com>
Thu, 17 Oct 2024 19:33:10 +0000 (04:33 +0900)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 29 Oct 2024 04:40:40 +0000 (21:40 -0700)
Syzbot reported that in directory operations after nilfs2 detects
filesystem corruption and degrades to read-only,
__block_write_begin_int(), which is called to prepare block writes, may
fail the BUG_ON check for accesses exceeding the folio/page size,
triggering a kernel bug.

This was found to be because the "checked" flag of a page/folio was not
cleared when it was discarded by nilfs2's own routine, which causes the
sanity check of directory entries to be skipped when the directory
page/folio is reloaded.  So, fix that.

This was necessary when the use of nilfs2's own page discard routine was
applied to more than just metadata files.

Link: https://lkml.kernel.org/r/20241017193359.5051-1-konishi.ryusuke@gmail.com
Fixes: 8c26c4e2694a ("nilfs2: fix issue with flush kernel thread after remount in RO mode because of driver's internal error or metadata corruption")
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Reported-by: syzbot+d6ca2daf692c7a82f959@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d6ca2daf692c7a82f959
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/nilfs2/page.c

index 5436eb0424bd151168982b6e86f535d0be9d69ab..10def4b55995631b0e01905d5a1b1d97be10d65a 100644 (file)
@@ -401,6 +401,7 @@ void nilfs_clear_folio_dirty(struct folio *folio)
 
        folio_clear_uptodate(folio);
        folio_clear_mappedtodisk(folio);
+       folio_clear_checked(folio);
 
        head = folio_buffers(folio);
        if (head) {