]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bcachefs: Fix infinite loop in journal_entry_btree_keys_to_text()
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 25 May 2025 21:04:11 +0000 (17:04 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Fri, 30 May 2025 05:21:12 +0000 (01:21 -0400)
Fix an infinite loop when bkey_i->k.u64s is 0.

This only happens in userspace, where 'bcachefs list_journal' can print
the entire contents of the journal, and non-dirty entries aren't
validated.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/journal_io.c

index a322c3d7123adbb8ecd8dfeaa56045f0eadbfd15..30122abf3e2c766e333155d337a2ab25a832ed2c 100644 (file)
@@ -429,6 +429,10 @@ static void journal_entry_btree_keys_to_text(struct printbuf *out, struct bch_fs
        bool first = true;
 
        jset_entry_for_each_key(entry, k) {
+               /* We may be called on entries that haven't been validated: */
+               if (!k->k.u64s)
+                       break;
+
                if (!first) {
                        prt_newline(out);
                        bch2_prt_jset_entry_type(out, entry->type);