]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: Fix array overrun with unknown btree roots
authorKent Overstreet <kent.overstreet@gmail.com>
Mon, 24 Jun 2019 22:11:35 +0000 (18:11 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:23 +0000 (17:08 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/recovery.c

index 2b7133e376e3d84cffc6452042321ceedd1b036f..e0df2c0a4fdf54b2747b570833c6b476e325de45 100644 (file)
@@ -379,7 +379,15 @@ static int journal_replay_entry_early(struct bch_fs *c,
 
        switch (entry->type) {
        case BCH_JSET_ENTRY_btree_root: {
-               struct btree_root *r = &c->btree_roots[entry->btree_id];
+               struct btree_root *r;
+
+               if (entry->btree_id >= BTREE_ID_NR) {
+                       bch_err(c, "filesystem has unknown btree type %u",
+                               entry->btree_id);
+                       return -EINVAL;
+               }
+
+               r = &c->btree_roots[entry->btree_id];
 
                if (entry->u64s) {
                        r->level = entry->level;