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 E5EC940860E; Tue, 21 Jul 2026 18:30:22 +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=1784658624; cv=none; b=ZRRO+X89SnxADfrTdoCPA+r8ENHURrKBn5jt2IO1XN2VFKmXmNlN2//74jXhfs94EXPstg5HCIEsdt42sENk3c4S57XBm+P9emN1FmKu3pYhApFTByGfUQ7oX5RtqFNmW2/0a0AcsJWXa1cdofk6J0OSGOZyd1b9ejXU586l4QQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784658624; c=relaxed/simple; bh=s+apYGW7tQupIGnxWpK5EW5EuPUycNYaF4DsZD7hrMs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k+kjhoy1qpoyucy32rnqQiQ7a9Ir0qjxvYozTMRrbcmfg7jAQTIVvTMq62lcmjFvVkdIIbjPrDrP34WNz8FehUVlPqVjz6EyJPDtKkYMWy5/6rFhckuOug9eTJQY5T/pMmV8KVFV8EgFSl0LuMNOaRiLV+LZTIAbPRoMlgyrVMY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=B4Ccpriq; 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="B4Ccpriq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BCB21F000E9; Tue, 21 Jul 2026 18:30:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784658622; bh=83yAKxz0Wo5BaqBWUICiOIK/b5zDyV5WAJff+YmG8n8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=B4CcpriqvPEW/4ncz9PO7WLQlmE+qPLCGn37PzDp/2YNTu8iKMfk3Cuzn3Zv2Xtc8 +OksQE7HB7txsPq7J+GdlSawhrjqibeThye7lVOD/XNIKF/gl5CWvvHHfXRAnTkIMF EjJm2xiRASWy6+DK5R3QJ3C+JejdjcyOSWaFcpEg= 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.18 1214/1611] jbd2: fix integer underflow in jbd2_journal_initialize_fast_commit() Date: Tue, 21 Jul 2026 17:22:10 +0200 Message-ID: <20260721152542.741665557@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152514.750365251@linuxfoundation.org> References: <20260721152514.750365251@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.18-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 @@ -2261,6 +2261,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;