Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

jbd2: gracefully abort instead of panicking on unlocked buffer

In jbd2_journal_get_create_access(), if the caller passes an unlocked
buffer, the code currently triggers a fatal J_ASSERT.

While an unlocked buffer here is a clear API violation and a bug in the
caller, crashing the entire system is an overly severe response. It brings
down the whole machine for a localized filesystem inconsistency.

Replace the J_ASSERT with a WARN_ON_ONCE to capture the offending caller's
stack trace, and return an error (-EINVAL). This allows the journal to
gracefully abort the transaction, protecting data integrity without
causing a kernel panic.

Signed-off-by: Milos Nikic <nikic.milos@gmail.com>
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Link: https://patch.msgid.link/20260304172016.23525-2-nikic.milos@gmail.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by

Milos Nikic and committed by
Theodore Ts'o
64924362 af1502f9

+6 -1
+6 -1
fs/jbd2/transaction.c
··· 1302 1302 goto out; 1303 1303 } 1304 1304 1305 - J_ASSERT_JH(jh, buffer_locked(jh2bh(jh))); 1305 + if (WARN_ON_ONCE(!buffer_locked(jh2bh(jh)))) { 1306 + err = -EINVAL; 1307 + spin_unlock(&jh->b_state_lock); 1308 + jbd2_journal_abort(journal, err); 1309 + goto out; 1310 + } 1306 1311 1307 1312 if (jh->b_transaction == NULL) { 1308 1313 /*