linux/fs/jbd2
Milos Nikic 46f82430fb jbd2: gracefully abort on checkpointing state corruptions
commit bac3190a8e 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 <nikic.milos@gmail.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Baokun Li <libaokun@linux.alibaba.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20260311041548.159424-1-nikic.milos@gmail.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-04-18 10:33:27 +02:00
..
checkpoint.c jbd2: gracefully abort on checkpointing state corruptions 2026-04-18 10:33:27 +02:00
commit.c jbd2: flush filesystem device before updating tail sequence 2025-01-23 17:15:48 +01:00
journal.c jbd2: fix the inconsistency between checksum and data in memory for journal sb 2026-01-19 13:10:06 +01:00
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
recovery.c jbd2: fix potential data lost in recovering journal raced with synchronizing fs bdev 2023-11-28 16:56:30 +00:00
revoke.c jbd2: rename jbd_debug() to jbd2_debug() 2023-09-23 11:10:00 +02:00
transaction.c jbd2: use a weaker annotation in journal handling 2026-01-19 13:09:50 +01:00