* [PATCH] jfs: skip BTROOT tlocks when releasing metapage pins in txAbort
@ 2026-11-29 15:06 zhengzongmin
0 siblings, 0 replies; only message in thread
From: zhengzongmin @ 2026-11-29 15:06 UTC (permalink / raw)
To: shaggy, jfs-discussion; +Cc: linux-fsdevel, linux-kernel
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-29 15:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 15:06 [PATCH] jfs: skip BTROOT tlocks when releasing metapage pins in txAbort zhengzongmin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox