From: kovalev@altlinux.org
To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
aivazian.tigran@gmail.com, stable@vger.kernel.org
Cc: lvc-patches@linuxtesting.org, dutyrok@altlinux.org,
kovalev@altlinux.org,
syzbot+d98fd19acd08b36ff422@syzkaller.appspotmail.com
Subject: [PATCH v3 2/2] bfs: ensure buffer is marked uptodate before marking it dirty
Date: Thu, 22 Aug 2024 19:12:19 +0300 [thread overview]
Message-ID: <20240822161219.459054-3-kovalev@altlinux.org> (raw)
In-Reply-To: <20240822161219.459054-1-kovalev@altlinux.org>
From: Vasiliy Kovalev <kovalev@altlinux.org>
Add a call to `set_buffer_uptodate(new)` in `bfs_move_block` before
marking the buffer as dirty. This change ensures the buffer is correctly
flagged as containing valid data after copying, preventing potential data
inconsistencies or corruption during writeback.
Found by Syzkaller:
WARNING: CPU: 1 PID: 5055 at fs/buffer.c:1176 mark_buffer_dirty+0x37b/0x3f0 fs/buffer.c:1176
Modules linked in:
CPU: 1 PID: 5055 Comm: syz-executor162 Not tainted 6.8.0-rc1-syzkaller-00049-g6098d87eaf31 #0
Hardware name: Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
RIP: 0010:mark_buffer_dirty+0x37b/0x3f0 fs/buffer.c:1176
Call Trace:
bfs_move_block fs/bfs/file.c:44 [inline]
bfs_move_blocks fs/bfs/file.c:57 [inline]
bfs_get_block+0x3e5/0xeb0 fs/bfs/file.c:126
__block_write_begin_int+0x4fb/0x16e0 fs/buffer.c:2103
__block_write_begin fs/buffer.c:2152 [inline]
block_write_begin+0xb1/0x490 fs/buffer.c:2211
bfs_write_begin+0x31/0xd0 fs/bfs/file.c:179
generic_perform_write+0x278/0x600 mm/filemap.c:3930
__generic_file_write_iter+0x1f9/0x240 mm/filemap.c:4025
generic_file_write_iter+0xe3/0x350 mm/filemap.c:4051
call_write_iter include/linux/fs.h:2085 [inline]
new_sync_write fs/read_write.c:497 [inline]
vfs_write+0x6d5/0x1100 fs/read_write.c:590
ksys_write+0x12f/0x250 fs/read_write.c:643
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xd3/0x250 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: syzbot+d98fd19acd08b36ff422@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d98fd19acd08b36ff422
Cc: stable@vger.kernel.org
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
---
fs/bfs/file.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/bfs/file.c b/fs/bfs/file.c
index 23773e62994024..3f0c506584560e 100644
--- a/fs/bfs/file.c
+++ b/fs/bfs/file.c
@@ -44,6 +44,7 @@ static int bfs_move_block(unsigned long from, unsigned long to,
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.33.8
prev parent reply other threads:[~2024-08-22 16:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-22 16:12 [PATCH v3 0/2] bfs: fix null-ptr-deref and possible warning in bfs_move_block() func kovalev
2024-08-22 16:12 ` [PATCH v3 1/2] bfs: prevent null pointer dereference in bfs_move_block() kovalev
2024-08-22 16:12 ` kovalev [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=20240822161219.459054-3-kovalev@altlinux.org \
--to=kovalev@altlinux.org \
--cc=aivazian.tigran@gmail.com \
--cc=dutyrok@altlinux.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-patches@linuxtesting.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+d98fd19acd08b36ff422@syzkaller.appspotmail.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