From: syzbot <syzbot+d083fd809394eab229a8@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] bfs: fix missing set_buffer_uptodate() in bfs_move_block()
Date: Mon, 30 Mar 2026 02:04:23 -0700 [thread overview]
Message-ID: <69ca3c97.050a0220.183828.0016.GAE@google.com> (raw)
In-Reply-To: <69ca049a.a70a0220.97f31.0127.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] bfs: fix missing set_buffer_uptodate() in bfs_move_block()
Author: kartikey406@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
bfs_move_block() uses sb_getblk() to obtain a buffer for the destination
block, copies data into it via memcpy(), and then calls mark_buffer_dirty().
However, sb_getblk() only allocates a buffer head without reading the block
from disk, leaving BH_Uptodate unset. This causes mark_buffer_dirty() to
trigger a warning:
WARNING: fs/buffer.c:1180 at mark_buffer_dirty+0x299/0x410
!buffer_uptodate(bh)
Since bfs_move_block() fully overwrites the destination buffer via memcpy(),
reading the block from disk is unnecessary. Instead, call
set_buffer_uptodate() after the copy to indicate the buffer contains valid
data before marking it dirty.
Additionally, sb_getblk() can return NULL but the original code never
checked for this, which would cause a NULL pointer dereference. Add a
proper NULL check with cleanup of the source buffer on failure.
Reported-by: syzbot+d083fd809394eab229a8@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d083fd809394eab229a8
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
fs/bfs/file.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/bfs/file.c b/fs/bfs/file.c
index d33d6bde992b..0a9b12b73324 100644
--- a/fs/bfs/file.c
+++ b/fs/bfs/file.c
@@ -40,7 +40,12 @@ static int bfs_move_block(unsigned long from, unsigned long to,
if (!bh)
return -EIO;
new = sb_getblk(sb, to);
+ if (!new) {
+ brelse(bh);
+ return -EIO;
+ }
memcpy(new->b_data, bh->b_data, bh->b_size);
+ set_buffer_uptodate(new);
mark_buffer_dirty(new);
bforget(bh);
brelse(new);
--
2.43.0
prev parent reply other threads:[~2026-03-30 9:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-30 5:05 [syzbot] [bfs?] WARNING in bfs_get_block syzbot
2026-03-30 9:04 ` syzbot [this message]
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=69ca3c97.050a0220.183828.0016.GAE@google.com \
--to=syzbot+d083fd809394eab229a8@syzkaller.appspotmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzkaller-bugs@googlegroups.com \
/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
Powered by JetHome