From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 31B852D9ECD; Mon, 13 Apr 2026 16:55:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776099342; cv=none; b=Z+CzFteI/gCKfjSk0kkiQDdbI9ueSnxaEjL61cbFXBz4DGSFj6SMegKC+2kf1FX7daZxPR86gZ72L5DLzV+8YO9f2fQOTPYBEAfoYg69v6woRvwbNyP9BheX9l6XFda1I8ZYPupuXOWPczfe+9uIi3tL4lk23zbn3gSOXqmaoUk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776099342; c=relaxed/simple; bh=Mkq6UOU5DOGg6eQXAGFYWji/VxHDfigJEVwg6ubRtaA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RG7q/i/W+90cqCta5jrfpPzyG2uTE0hNF8HGIHuuuxpfDh4eqGCDtjXfNGK3P+0+EcWvH6GYlNeDP2J+12n9JUlDf9g0jZGvJ5C5Wl+5nphagB9qU7rQMdm/6okxhF1MDhIyoQqCgDWAnOZyAAtZztQekKnOA8qruCu5FGrLGJQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ZuvkTzaX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ZuvkTzaX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBFE6C2BCAF; Mon, 13 Apr 2026 16:55:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776099342; bh=Mkq6UOU5DOGg6eQXAGFYWji/VxHDfigJEVwg6ubRtaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZuvkTzaXrv86IyynXOQlMOWXMjMzPt4IylriUFlFf6CrdH08nsFYBNiWkej5McKN5 qEoktM36uduslH/izJDXtDT2aYb7QZxSkJTMAbWkOl2Bem9U/tEYIncvVIYKCuw5Ih VDoBZB7m4grJWjPdUZfcyBKH2CxQFZgBI7ZW6Vzk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Milos Nikic , Andreas Dilger , Zhang Yi , Baokun Li , Jan Kara , Theodore Tso , stable@kernel.org Subject: [PATCH 5.10 303/491] jbd2: gracefully abort on checkpointing state corruptions Date: Mon, 13 Apr 2026 17:59:08 +0200 Message-ID: <20260413155830.385886345@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155819.042779211@linuxfoundation.org> References: <20260413155819.042779211@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 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Milos Nikic commit bac3190a8e79beff6ed221975e0c9b1b5f2a21da upstream. This patch targets two internal state machine invariants in checkpoint.c residing inside functions that natively return integer error codes. - In jbd2_cleanup_journal_tail(): A blocknr of 0 indicates a severely corrupted journal superblock. Replaced the J_ASSERT with a WARN_ON_ONCE and a graceful journal abort, returning -EFSCORRUPTED. - In jbd2_log_do_checkpoint(): Replaced the J_ASSERT_BH checking for an unexpected buffer_jwrite state. If the warning triggers, we explicitly drop the just-taken get_bh() reference and call __flush_batch() to safely clean up any previously queued buffers in the j_chkpt_bhs array, preventing a memory leak before returning -EFSCORRUPTED. Signed-off-by: Milos Nikic Reviewed-by: Andreas Dilger Reviewed-by: Zhang Yi Reviewed-by: Baokun Li Reviewed-by: Jan Kara Link: https://patch.msgid.link/20260311041548.159424-1-nikic.milos@gmail.com Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/jbd2/checkpoint.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) --- a/fs/jbd2/checkpoint.c +++ b/fs/jbd2/checkpoint.c @@ -303,7 +303,15 @@ restart: */ BUFFER_TRACE(bh, "queue"); get_bh(bh); - J_ASSERT_BH(bh, !buffer_jwrite(bh)); + if (WARN_ON_ONCE(buffer_jwrite(bh))) { + put_bh(bh); /* drop the ref we just took */ + spin_unlock(&journal->j_list_lock); + /* Clean up any previously batched buffers */ + if (batch_count) + __flush_batch(journal, &batch_count); + jbd2_journal_abort(journal, -EFSCORRUPTED); + return -EFSCORRUPTED; + } journal->j_chkpt_bhs[batch_count++] = bh; transaction->t_chp_stats.cs_written++; transaction->t_checkpoint_list = jh->b_cpnext; @@ -361,7 +369,10 @@ int jbd2_cleanup_journal_tail(journal_t if (!jbd2_journal_get_log_tail(journal, &first_tid, &blocknr)) return 1; - J_ASSERT(blocknr != 0); + if (WARN_ON_ONCE(blocknr == 0)) { + jbd2_journal_abort(journal, -EFSCORRUPTED); + return -EFSCORRUPTED; + } /* * We need to make sure that any blocks that were recently written out