Linux filesystem development
 help / color / mirror / Atom feed
From: zhengzongmin <zhengzongmin8@gmail.com>
To: shaggy@kernel.org, jfs-discussion@lists.sourceforge.net
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] jfs: skip BTROOT tlocks when releasing metapage pins in txAbort
Date: Sun, 29 Nov 2026 07:06:58 -0800 (PST)	[thread overview]
Message-ID: <6b0c3f92.edd7c018.6fd88.e89b@mx.google.com> (raw)

From: zhengzongmin <zhengzongmin8@gmail.com>
Date: Sun, 29 Nov 2026 23:03:24 +0800
Subject: [PATCH] jfs: skip BTROOT tlocks when releasing metapage pins in
 txAbort

syzbot reported a slab-use-after-free read in txUnlock() on an aborted
transaction (extid 706dff62c3dd6a366ff9).

diWrite() rebinds an inode's inline B+tree root locks (xtlid/blid,
marked tlckBTROOT) to the on-disk inode-extent metapage without taking a
metapage_nohomeok() pin. txUnlock() correctly skips such locks with a
tlckBTROOT check, but txAbort() does not: on abort it calls
LogSyncRelease(mp) for every COMMIT_PAGE metapage with mp->lsn set,
over-decrementing mp->nohomeok to zero. That lets writeback free the
metapage before an earlier lazy transaction reaches txUnlock(), which
then reads freed memory.

Skip tlckBTROOT tlocks in txAbort(), matching txUnlock().

Reported-by: syzbot+706dff62c3dd6a366ff9@syzkaller.appspotmail.com
Signed-off-by: zhengzongmin <zhengzongmin8@gmail.com>
---
 fs/jfs/jfs_txnmgr.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
index 083dbbb..a5f1ed3 100644
--- a/fs/jfs/jfs_txnmgr.c
+++ b/fs/jfs/jfs_txnmgr.c
@@ -2618,8 +2618,15 @@ void txAbort(tid_t tid, int dirty)
 			 * transaction(s) but has not been paged, i.e.,
 			 * it may be on logsync list even though it has not
 			 * been logged for the current tx.)
+			 *
+			 * A tlckBTROOT tlock only rebinds an inode's inline
+			 * B+tree root to the dinode metapage in diWrite() and
+			 * never took a metapage_nohomeok() pin, so releasing it
+			 * here would drop a reference we never acquired. Match
+			 * txUnlock() and skip these locks.
 			 */
-			if (mp->xflag & COMMIT_PAGE && mp->lsn)
+			if (!(tlck->type & tlckBTROOT) &&
+			    (mp->xflag & COMMIT_PAGE) && mp->lsn)
 				LogSyncRelease(mp);
 		}
 		/* insert tlock at head of freelist */
-- 
2.55.0.windows.3

                 reply	other threads:[~2026-11-29 15:06 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=6b0c3f92.edd7c018.6fd88.e89b@mx.google.com \
    --to=zhengzongmin8@gmail.com \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shaggy@kernel.org \
    /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