diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-02-22 17:57:59 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:54 -0400 |
commit | 64784ade4fd75cdd47d7ddfbfcbed3506fe10523 (patch) | |
tree | f0ef0f061a485560cd36a27725eb6c99300a8383 /fs/bcachefs/extents.h | |
parent | 43b0e8787ecb92760202c0682172141ed4b22c62 (diff) | |
download | lwn-64784ade4fd75cdd47d7ddfbfcbed3506fe10523.tar.gz lwn-64784ade4fd75cdd47d7ddfbfcbed3506fe10523.zip |
bcachefs: Fix buffer overrun in ec_stripe_update_extent()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/extents.h')
-rw-r--r-- | fs/bcachefs/extents.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/bcachefs/extents.h b/fs/bcachefs/extents.h index c52a09832857..2e37543a6229 100644 --- a/fs/bcachefs/extents.h +++ b/fs/bcachefs/extents.h @@ -76,6 +76,18 @@ static inline size_t extent_entry_u64s(const union bch_extent_entry *entry) return extent_entry_bytes(entry) / sizeof(u64); } +static inline void __extent_entry_insert(struct bkey_i *k, + union bch_extent_entry *dst, + union bch_extent_entry *new) +{ + union bch_extent_entry *end = bkey_val_end(bkey_i_to_s(k)); + + memmove_u64s_up_small((u64 *) dst + extent_entry_u64s(new), + dst, (u64 *) end - (u64 *) dst); + k->k.u64s += extent_entry_u64s(new); + memcpy_u64s_small(dst, new, extent_entry_u64s(new)); +} + static inline bool extent_entry_is_ptr(const union bch_extent_entry *e) { return extent_entry_type(e) == BCH_EXTENT_ENTRY_ptr; |