From: wuyankun <wuyankun@uniontech.com>
To: konishi.ryusuke@gmail.com, slava@dubeyko.com
Cc: linux-nilfs@vger.kernel.org, linux-kernel@vger.kernel.org,
syzkaller-bugs@googlegroups.com,
syzbot+c37bed40868932d790e9@syzkaller.appspotmail.com,
wuyankun@uniontech.com
Subject: [PATCH] nilfs2: prevent double insertion of b_assoc_buffers in dirty buffer lookup
Date: Thu, 25 Jun 2026 13:26:39 +0800 [thread overview]
Message-ID: <20260625052639.241024-1-wuyankun@uniontech.com> (raw)
syzbot reported list corruption caused by double list_add_tail() on
bh->b_assoc_buffers in nilfs_lookup_dirty_data_buffers().
A buffer_head can still be dirty and not under async write while already
linked on another association list. Add list state checks before enqueueing
in both data and node dirty buffer scanners to avoid re-adding already
linked nodes.
Reported-by: syzbot+c37bed40868932d790e9@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=c37bed40868932d790e9
Signed-off-by: wuyankun <wuyankun@uniontech.com>
---
fs/nilfs2/segment.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index 1491a4d4b1e1..09202d155903 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -741,6 +741,8 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode,
do {
if (!buffer_dirty(bh) || buffer_async_write(bh))
continue;
+ if (!list_empty(&bh->b_assoc_buffers))
+ continue;
get_bh(bh);
list_add_tail(&bh->b_assoc_buffers, listp);
ndirties++;
@@ -779,7 +781,8 @@ static void nilfs_lookup_dirty_node_buffers(struct inode *inode,
bh = head = folio_buffers(fbatch.folios[i]);
do {
if (buffer_dirty(bh) &&
- !buffer_async_write(bh)) {
+ !buffer_async_write(bh) &&
+ list_empty(&bh->b_assoc_buffers)) {
get_bh(bh);
list_add_tail(&bh->b_assoc_buffers,
listp);
--
2.20.1
next reply other threads:[~2026-06-25 5:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-25 5:26 wuyankun [this message]
2026-06-25 10:43 ` [PATCH] nilfs2: prevent double insertion of b_assoc_buffers in dirty buffer lookup Ryusuke Konishi
2026-06-30 17:55 ` Ryusuke Konishi
2026-07-01 1:53 ` wuyankun
-- strict thread matches above, loose matches on Subject: below --
2026-06-24 19:59 [syzbot] [nilfs?] BUG: corrupted list in nilfs_lookup_dirty_data_buffers syzbot
2026-06-25 9:14 ` [PATCH] nilfs2: prevent double insertion of b_assoc_buffers in dirty buffer lookup wuyankun
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=20260625052639.241024-1-wuyankun@uniontech.com \
--to=wuyankun@uniontech.com \
--cc=konishi.ryusuke@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nilfs@vger.kernel.org \
--cc=slava@dubeyko.com \
--cc=syzbot+c37bed40868932d790e9@syzkaller.appspotmail.com \
--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