From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C280B356746; Tue, 21 Jul 2026 19:56:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663765; cv=none; b=al+JDM9f2HSNSydtvuKU+uM0z4DaolaRCHolDQ51Txgfxf31t1XhV7n9dKpEPojSjq4f5lEcJnpcGR5zYBF8UDhe7cyoiugJvCIl8KQ/2jAfSHpVTEDQHaBsf8Ig24byDkvmwxr8Ve+tdAVc2L0wnwIqktAk5CARQzX7Avbi/8U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663765; c=relaxed/simple; bh=u4H63ovQAWXEou06u9NacWj3Ta0X3pvJTg6jxZuTZe4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QdWVXpj6OeZNg4zInlB69MULq/2tEDIGbFjJ+vgUrv8/m9cpJSy36axE3pjgURB/Jss+m5g22Ft2MPOHC/1PNLR0jbBSrqdL/zd9ARnLsSnI7Fj3C31SD2c5YPMg9L+64FOGd6XCaDm6Wv600EbRGi42dDv5ixV3X9CXQ4gkQU4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NMWla1GA; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="NMWla1GA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A1921F000E9; Tue, 21 Jul 2026 19:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784663763; bh=QEK/qHHC8668HCdRKzqVdKvCBSe25xjvJmqaEopSS+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NMWla1GAW+FlbrMGoRUOPZLbUrObc/5CqMQIVx7PasBQGRlrcJMurdJx1bC3ivjye IGy1gZEK4LzwQki4N142RZoJCrJTJv26g5xP39uX+L7WWQP1BbItyDauSq7xWw0Lwh qr9SSQwYb0GvqWFT5sgGZluSbTd+2xU2NnnPb/Gc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ian Bridges , syzbot+e9c15ff790cea6a0cfae@syzkaller.appspotmail.com, Joseph Qi , Mark Fasheh , Joel Becker , Junxiao Bi , Changwei Ge , Jun Piao , Heming Zhao , Andrew Morton Subject: [PATCH 6.12 0946/1276] ocfs2: fix NULL h_transaction deref in ocfs2_assure_trans_credits Date: Tue, 21 Jul 2026 17:23:09 +0200 Message-ID: <20260721152507.201911303@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152446.065700225@linuxfoundation.org> References: <20260721152446.065700225@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ian Bridges commit f9ab30c96b0f00c20c6dac93681bdae3a033d229 upstream. [BUG] A direct write over unwritten extents can panic the kernel in ocfs2_assure_trans_credits() when the journal aborts during DIO completion. The crash is a general protection fault from a NULL pointer dereference. [CAUSE] ocfs2_dio_end_io_write() loops over a direct write's unwritten extents, marking each written under a single journal handle. If the journal aborts (for example after an I/O error) while the extent tree is being updated, the handle is left aborted with its transaction pointer cleared. The extent merge treats that failure as not critical and reports success, so the loop keeps using the handle. ocfs2_assure_trans_credits() reads the handle's remaining credits without first checking whether the handle is aborted, and that read dereferences the cleared transaction pointer. [FIX] A journal abort is recorded in the handle itself, so callers are expected to test the handle rather than rely on a returned error. Make ocfs2_assure_trans_credits() do that, as the other ocfs2 journal helpers already do, and return -EROFS when the handle is aborted. Link: https://lore.kernel.org/airKTsM1fRVN-Wj7@dev Fixes: be346c1a6eeb ("ocfs2: fix DIO failure due to insufficient transaction credits") Signed-off-by: Ian Bridges Reported-by: syzbot+e9c15ff790cea6a0cfae@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=e9c15ff790cea6a0cfae Reviewed-by: Joseph Qi Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Changwei Ge Cc: Jun Piao Cc: Heming Zhao Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- fs/ocfs2/journal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -476,8 +476,12 @@ bail: */ int ocfs2_assure_trans_credits(handle_t *handle, int nblocks) { - int old_nblks = jbd2_handle_buffer_credits(handle); + int old_nblks; + if (is_handle_aborted(handle)) + return -EROFS; + + old_nblks = jbd2_handle_buffer_credits(handle); trace_ocfs2_assure_trans_credits(old_nblks); if (old_nblks >= nblocks) return 0;