diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 11:33:02 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-31 12:18:37 -0400 |
commit | 9db2f86060a8e54e80f99e3c3366832ce6a67d76 (patch) | |
tree | e83bd22e7eae0465b2098e5b20e605b32afcc7e7 /fs/bcachefs/extents.c | |
parent | 2d39081291470750cc605c917531d7cd85aebf94 (diff) |
bcachefs: Check for too-large encoded extents
We don't yet repair (split) them, just check.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/extents.c')
-rw-r--r-- | fs/bcachefs/extents.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/bcachefs/extents.c b/fs/bcachefs/extents.c index 1b25f84e4b9c..38077b3886d7 100644 --- a/fs/bcachefs/extents.c +++ b/fs/bcachefs/extents.c @@ -1207,6 +1207,14 @@ int bch2_bkey_ptrs_invalid(const struct bch_fs *c, struct bkey_s_c k, return -BCH_ERR_invalid_bkey; } crc_since_last_ptr = true; + + if (crc_is_encoded(crc) && + (crc.uncompressed_size > c->opts.encoded_extent_max >> 9) && + (flags & (BKEY_INVALID_WRITE|BKEY_INVALID_COMMIT))) { + prt_printf(err, "too large encoded extent"); + return -BCH_ERR_invalid_bkey; + } + break; case BCH_EXTENT_ENTRY_stripe_ptr: if (have_ec) { |