Skip to content

Commit c257731

Browse files
konissmb49
authored andcommitted
nilfs2: fix kernel bug due to missing clearing of buffer delay flag
BugLink: https://bugs.launchpad.net/bugs/2097575 commit 6ed469d upstream. Syzbot reported that after nilfs2 reads a corrupted file system image and degrades to read-only, the BUG_ON check for the buffer delay flag in submit_bh_wbc() may fail, causing a kernel bug. This is because the buffer delay flag is not cleared when clearing the buffer state flags to discard a page/folio or a buffer head. So, fix this. This became necessary when the use of nilfs2's own page clear routine was expanded. This state inconsistency does not occur if the buffer is written normally by log writing. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com> Link: https://lore.kernel.org/r/20241015213300.7114-1-konishi.ryusuke@gmail.com Fixes: 8c26c4e ("nilfs2: fix issue with flush kernel thread after remount in RO mode because of driver's internal error or metadata corruption") Reported-by: syzbot+985ada84bf055a575c07@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=985ada84bf055a575c07 Cc: stable@vger.kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 78ab292 commit c257731

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/nilfs2/page.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ void nilfs_forget_buffer(struct buffer_head *bh)
7777
const unsigned long clear_bits =
7878
(BIT(BH_Uptodate) | BIT(BH_Dirty) | BIT(BH_Mapped) |
7979
BIT(BH_Async_Write) | BIT(BH_NILFS_Volatile) |
80-
BIT(BH_NILFS_Checked) | BIT(BH_NILFS_Redirected));
80+
BIT(BH_NILFS_Checked) | BIT(BH_NILFS_Redirected) |
81+
BIT(BH_Delay));
8182

8283
lock_buffer(bh);
8384
set_mask_bits(&bh->b_state, clear_bits, 0);
@@ -414,7 +415,8 @@ void nilfs_clear_folio_dirty(struct folio *folio, bool silent)
414415
const unsigned long clear_bits =
415416
(BIT(BH_Uptodate) | BIT(BH_Dirty) | BIT(BH_Mapped) |
416417
BIT(BH_Async_Write) | BIT(BH_NILFS_Volatile) |
417-
BIT(BH_NILFS_Checked) | BIT(BH_NILFS_Redirected));
418+
BIT(BH_NILFS_Checked) | BIT(BH_NILFS_Redirected) |
419+
BIT(BH_Delay));
418420

419421
bh = head;
420422
do {

0 commit comments

Comments
 (0)