bcachefs: Check for extents with too many ptrs
We have a hardcoded maximum on number of pointers in an extent that's used by some other data structures - notably bch_devs_list - but we weren't actually checking for it. Oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
1c6ff39445
commit
b5f73fd79f
1 changed files with 7 additions and 0 deletions
|
@ -1078,6 +1078,7 @@ int bch2_bkey_ptrs_invalid(const struct bch_fs *c, struct bkey_s_c k,
|
|||
struct bch_extent_crc_unpacked crc;
|
||||
unsigned size_ondisk = k.k->size;
|
||||
unsigned nonce = UINT_MAX;
|
||||
unsigned nr_ptrs = 0;
|
||||
int ret;
|
||||
|
||||
if (bkey_is_btree_ptr(k.k))
|
||||
|
@ -1102,6 +1103,7 @@ int bch2_bkey_ptrs_invalid(const struct bch_fs *c, struct bkey_s_c k,
|
|||
false, err);
|
||||
if (ret)
|
||||
return ret;
|
||||
nr_ptrs++;
|
||||
break;
|
||||
case BCH_EXTENT_ENTRY_crc32:
|
||||
case BCH_EXTENT_ENTRY_crc64:
|
||||
|
@ -1140,6 +1142,11 @@ int bch2_bkey_ptrs_invalid(const struct bch_fs *c, struct bkey_s_c k,
|
|||
}
|
||||
}
|
||||
|
||||
if (nr_ptrs >= BCH_BKEY_PTRS_MAX) {
|
||||
prt_str(err, "too many ptrs");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue