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 CA4353644B3; Tue, 21 Jul 2026 19:53:59 +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=1784663640; cv=none; b=TrWBzr7M5KELXBlvF1ziun0LDgDW/fz5W+sGJ69xNWrKVZgXp8oh6VWjaCejKINdcAlHgNR+HCo7MCZAnpIBl1LHp/x5qKPlWg6JPyysizdOWXJdDk/TvBIwpEzPCEpK7gkLr4+c2J6EWb0fRDewMdAQWCUb96kIT4+qSaiMrGs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663640; c=relaxed/simple; bh=n575CDj/ZHPP2ECaFrMklIGN8RjrJ7LCHa6vx5jNJ54=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VQfofo7vC34/VcAUtWBdZN6ylUjqWGRw1cQka4jcOY5HDJz9UjBpIjd4ksHwd1MzPXvdiGtCUFydfCmrtx7kWabjVJxv4Fz0d4WRGbv6S71ugGNKRVO6L+mf8ZfbhE4FghnZfWFtqZS2VYx9ePqdWrKc1AWOqVEa2M4AO0607BY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ez9v2RmF; 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="ez9v2RmF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 457F91F00A3A; Tue, 21 Jul 2026 19:53:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784663639; bh=fxjBbUyLItF0sBVHhkXtLLd6Oa68zGxlhVd4QQexeX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ez9v2RmFxEjGF4Le98Zn1H2zCK6Rd/H5nb4glYnhlis3AfTObBBWjDvCd0bLC2i+9 NEKAoErApMt3VyKzLyPm06oNpUlKO2yIvFghmEGvOGVun7eI5c/QLSxDzkttXrTWkt Cn8h/wsZ+91qSLI5cU7gNFCfK/jnEfJFrszIk10s= 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.12 0899/1276] jbd2: fix integer underflow in jbd2_journal_initialize_fast_commit() Date: Tue, 21 Jul 2026 17:22:22 +0200 Message-ID: <20260721152506.160866111@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: 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 @@ -2273,6 +2273,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;