From: zhengzongmin 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 --- 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