From: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>,
Jan Kara <jack@suse.cz>, Christian Brauner <brauner@kernel.org>,
Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>,
syzbot+bffc332f376fdab5cef0@syzkaller.appspotmail.com
Subject: [PATCH] minix: don't re-dirty the superblock buffer after a write failure
Date: Mon, 12 Oct 2026 23:31:44 +0700 [thread overview]
Message-ID: <20261012163145.398471-1-ngocthang2710.1999@gmail.com> (raw)
minix keeps the superblock buffer head (sbi->s_sbh) pinned for the
lifetime of the mount and modifies it in place. If a write to the
backing device fails, end_buffer_write_sync() clears BH_Uptodate on
that buffer. minix_put_super() and minix_reconfigure() then call
mark_buffer_dirty() on it unconditionally and trip:
WARNING: fs/buffer.c:991 at mark_buffer_dirty+0x299/0x410
!buffer_uptodate(bh)
Call Trace:
minix_put_super+0x16d/0x460 fs/minix/inode.c:70
generic_shutdown_super+0x13d/0x2d0 fs/super.c:751
kill_block_super+0x44/0xa0 fs/super.c:1903
deactivate_locked_super+0xbe/0x110 fs/super.c:586
cleanup_mnt+0x204/0x2a0 fs/namespace.c:1392
Reproduced by mounting a minix image on a loop device, making all
writes to it fail with fail_make_request, and unmounting.
Skip the s_state update and the dirtying in minix_put_super() when the
buffer is no longer uptodate, and fail a state-changing remount with
-EIO, the same way hfs handles its MDB buffers.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: syzbot+bffc332f376fdab5cef0@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=bffc332f376fdab5cef0
Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
---
fs/minix/inode.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index daf83e4ff25c..5c0ad33b85e0 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -64,7 +64,8 @@ static void minix_put_super(struct super_block *sb)
int i;
struct minix_sb_info *sbi = minix_sb(sb);
- if (!sb_rdonly(sb)) {
+ /* a failed write clears uptodate; don't re-dirty the stale buffer */
+ if (!sb_rdonly(sb) && buffer_uptodate(sbi->s_sbh)) {
if (sbi->s_version != MINIX_V3) /* s_state is now out from V3 sb */
sbi->s_ms->s_state = sbi->s_mount_state;
mark_buffer_dirty(sbi->s_sbh);
@@ -146,6 +147,8 @@ static int minix_reconfigure(struct fs_context *fc)
ms = sbi->s_ms;
if ((bool)(fc->sb_flags & SB_RDONLY) == sb_rdonly(sb))
return 0;
+ if (!buffer_uptodate(sbi->s_sbh))
+ return -EIO;
if (fc->sb_flags & SB_RDONLY) {
if (ms->s_state & MINIX_VALID_FS ||
!(sbi->s_mount_state & MINIX_VALID_FS))
--
2.43.0
reply other threads:[~2026-10-12 16:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261012163145.398471-1-ngocthang2710.1999@gmail.com \
--to=ngocthang2710.1999@gmail.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+bffc332f376fdab5cef0@syzkaller.appspotmail.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®