All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduard Zateev <hackerowskiy@gmail.com>
To: cem@kernel.org
Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	Eduard Zateev <hackerowskiy@gmail.com>,
	syzbot+9d8e687768d0f38c1f09@syzkaller.appspotmail.com
Subject: [PATCH] xfs: preserve buffer item with outstanding references
Date: Tue, 20 Oct 2026 22:04:31 +0200	[thread overview]
Message-ID: <20261020200433.3298861-1-hackerowskiy@gmail.com> (raw)

The buffer log item can still be referenced by the CIL after the buffer's
synchronous write completes.  In this case xfs_buf_item_relse() is called
from xfs_buf_ioend() with bli_refcount non-zero.  Freeing the item leaves
a stale pointer in the CIL, which xlog_cil_committed() later dereferences.

Restore the reference-count check removed by commit d2fe5c4c8d25
("xfs: rearrange code in xfs_buf_item.c").  If references remain, keep
the log item attached to the buffer so that its final reference release
can perform cleanup.

Build-tested: fs/xfs/xfs_buf_item.o (ARCH=arm64, W=1).
The syzbot report does not include a reproducer, so runtime testing was
not possible.

Fixes: d2fe5c4c8d25 ("xfs: rearrange code in xfs_buf_item.c")
Reported-by: syzbot+9d8e687768d0f38c1f09@syzkaller.appspotmail.com
Closes: https://syzbot.org/bug?extid=9d8e687768d0f38c1f09
Assisted-by: LLM OpenAI Codex

---
 fs/xfs/xfs_buf_item.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 1a4ef34af8d..80f0cf12825 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -80,7 +80,8 @@ xfs_buf_item_relse(
 	trace_xfs_buf_item_relse(bp, _RET_IP_);
 
 	ASSERT(!test_bit(XFS_LI_IN_AIL, &bip->bli_item.li_flags));
-	ASSERT(atomic_read(&bip->bli_refcount) == 0);
+	if (atomic_read(&bip->bli_refcount))
+		return;
 
 	bp->b_log_item = NULL;
 	xfs_buf_rele(bp);

Signed-off-by: Eduard Zateev <hackerowskiy@gmail.com>

             reply	other threads:[~2026-10-20 20:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 20:04 Eduard Zateev [this message]
2026-10-20 20:55 ` [PATCH] xfs: preserve buffer item with outstanding references Dave Chinner

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=20261020200433.3298861-1-hackerowskiy@gmail.com \
    --to=hackerowskiy@gmail.com \
    --cc=cem@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=syzbot+9d8e687768d0f38c1f09@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.