nilfs2-fix-warning-in-mark_buffer_dirty-due-to-discarded-buffer-reuse.patch removed from -mm tree
The quilt patch titled
Subject: nilfs2: fix WARNING in mark_buffer_dirty due to discarded buffer reuse
has been removed from the -mm tree. Its filename was
nilfs2-fix-warning-in-mark_buffer_dirty-due-to-discarded-buffer-reuse.patch
This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Ryusuke Konishi <[email protected]>
Subject: nilfs2: fix WARNING in mark_buffer_dirty due to discarded buffer reuse
Date: Fri, 18 Aug 2023 22:18:04 +0900
A syzbot stress test using a corrupted disk image reported that mark_buffer_dirty() called from __nilfs_mark_inode_dirty() or nilfs_palloc_commit_alloc_entry() may output a kernel warning, and can panic if the kernel is booted with panic_on_warn.
This is because nilfs2 keeps buffer pointers in local structures for some metadata and reuses them, but such buffers may be forcibly discarded by nilfs_clear_dirty_page() in some critical situations.
This issue is reported to appear after commit 28a65b49eb53 ("nilfs2: do not write dirty data after degenerating to read-only"), but the issue has potentially existed before.
Fix this issue by checking the uptodate flag when attempting to reuse an internally held buffer, and reloading the metadata instead of reusing the buffer if the flag was lost.
---
fs/nilfs2/alloc.c | 3 ++- fs/nilfs2/inode.c | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-)
fs/nilfs2/alloc.c renamed from fs/nilfs2/alloc.c~nilfs2-fix-warning-in-mark_buffer_dirty-due-to-discarded-buffer-reuse +2 -1
@@ -205,7 +205,8 @@ static int nilfs_palloc_get_block(structint ret;spin_lock (lock); -if (prev->bh && blkoff == prev->blkoff) { +if (prev->bh && blkoff == prev->blkoff && +likely (buffer_uptodate (prev->bh))) {get_bh (prev->bh); *bhp = prev->bh;spin_unlock (lock);
fs/nilfs2/inode.c renamed from fs/nilfs2/inode.c~nilfs2-fix-warning-in-mark_buffer_dirty-due-to-discarded-buffer-reuse +5 -2
@@ -1025,7 +1025,7 @@ int nilfs_load_inode_block(struct inodeint err;spin_lock (&nilfs->ns_inode_lock); -if (ii->i_bh ==NULL ) { +if (ii->i_bh ==NULL ||unlikely (!buffer_uptodate (ii->i_bh))) {spin_unlock (&nilfs->ns_inode_lock); err =nilfs_ifile_get_inode_block (ii->i_root->ifile, inode->i_ino, pbh);
@@ -1034,7 +1034,10 @@ int nilfs_load_inode_block(struct inodespin_lock (&nilfs->ns_inode_lock);if (ii->i_bh ==NULL ) ii->i_bh = *pbh; -else { +else if (unlikely (!buffer_uptodate (ii->i_bh))) { +__brelse (ii->i_bh); + ii->i_bh = *pbh; + }else {brelse (*pbh); *pbh = ii->i_bh; }
_
Patches currently in -mm which might be from [email protected] are