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 756DD366816; Tue, 21 Jul 2026 20:52:58 +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=1784667179; cv=none; b=FTyiPGxJLmyrx8mWUTjkU5kxG9tHUlrSZ2oxshLoKbVjDjrUD62hyZQ9NsrEOMlODBehLvnmSHA535zvu2cmCRkXMysczSOiReOgC3GfdTEwRb+H6Aufcq8tfUlV0r9kq+n8pgJXUuBGDuv6k0zSEeTm2L2xAyTukCoLIKUi11A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784667179; c=relaxed/simple; bh=0WwQVAcr3j21gsMXgukEUpvKo+Lm+erGlOYWpbDxuOA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R8ThKv94Bf0Hw02LNvRU9K5yT7MfMQ6+2ZutE5Sa1ZGn/uAX+TQnEsIieZnNiU3OCEXBrKX/rcxUuN2s8eAx86/2S5ESbjXoJzYq2meWrUc7lE5sdr0wtGecUbZjfBswc/h+JWnwhrRMU3UEr23KspA2RQOo8L4dp2tAOYr1cpM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=1ONwjU5v; 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="1ONwjU5v" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E444D1F000E9; Tue, 21 Jul 2026 20:52:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784667178; bh=a7RdMXLBEJ2yRUGbfBeFqjPiHYnw4hIYjWFEy1wa+L4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1ONwjU5vMQ03+0tMReEJZOcnck5UMddTJVgFsWFKuUpOsiqtjs5vY5tyFRn0ld2r2 k19RAh+2p37imR/VPHoxnaBTO2J5Hiij7JdZ+gVx1ESKqXO2kdRQJ8B73QTH2/+KJG fT8CEYI/jO9fQysZacX89hM4lv8zM1JnLWMCZewY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuhao Jiang , Junrui Luo , Baokun Li , Zhang Yi , Jan Kara , Theodore Tso Subject: [PATCH 6.6 0961/1266] jbd2: fix integer underflow in jbd2_journal_initialize_fast_commit() Date: Tue, 21 Jul 2026 17:23:18 +0200 Message-ID: <20260721152503.331964952@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152441.786066624@linuxfoundation.org> References: <20260721152441.786066624@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Junrui Luo commit 289a2ca0c9b7eae74f93fc213b0b971669b8683d upstream. jbd2_journal_initialize_fast_commit() validates journal capacity by checking (journal->j_last - num_fc_blks < JBD2_MIN_JOURNAL_BLOCKS). Both j_last and num_fc_blks are unsigned, so when num_fc_blks exceeds j_last the subtraction wraps to a large value, bypassing the bounds check. The resulting underflow corrupts j_last, j_fc_first, and j_free, leading to journal abort. Fix by checking num_fc_blks against j_last before the subtraction, returning -EFSCORRUPTED. Fixes: 6866d7b3f2bb ("ext4 / jbd2: add fast commit initialization") Reported-by: Yuhao Jiang Cc: stable@vger.kernel.org Signed-off-by: Junrui Luo Fixes: e029c5f27987 ("ext4: make num of fast commit blocks configurable") Reviewed-by: Baokun Li Fixes: e029c5f279872 ("ext4: make num of fast commit blocks configurable") Reviewed-by: Zhang Yi Reviewed-by: Jan Kara Link: https://patch.msgid.link/SYBPR01MB7881663C927DE9D7BBF4D1DFAF062@SYBPR01MB7881.ausprd01.prod.outlook.com Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/jbd2/journal.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -2303,6 +2303,8 @@ jbd2_journal_initialize_fast_commit(jour unsigned long long num_fc_blks; num_fc_blks = jbd2_journal_get_num_fc_blks(sb); + if (num_fc_blks > journal->j_last) + return -EFSCORRUPTED; if (journal->j_last - num_fc_blks < JBD2_MIN_JOURNAL_BLOCKS) return -ENOSPC;