Commit 1ae97334 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Don't overflow stack in bch2_extent_merge_inline()

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 5884fddf
...@@ -41,10 +41,7 @@ struct bkey_s { ...@@ -41,10 +41,7 @@ struct bkey_s {
#define bkey_next(_k) vstruct_next(_k) #define bkey_next(_k) vstruct_next(_k)
static inline unsigned bkey_val_u64s(const struct bkey *k) #define bkey_val_u64s(_k) ((_k)->u64s - BKEY_U64s)
{
return k->u64s - BKEY_U64s;
}
static inline size_t bkey_val_bytes(const struct bkey *k) static inline size_t bkey_val_bytes(const struct bkey *k)
{ {
......
...@@ -1651,6 +1651,10 @@ static bool bch2_extent_merge_inline(struct bch_fs *c, ...@@ -1651,6 +1651,10 @@ static bool bch2_extent_merge_inline(struct bch_fs *c,
EBUG_ON(bkey_written(b, m)); EBUG_ON(bkey_written(b, m));
if (bkey_val_u64s(l) > BKEY_EXTENT_VAL_U64s_MAX ||
bkey_val_u64s(r) > BKEY_EXTENT_VAL_U64s_MAX)
return BCH_MERGE_NOMERGE;
/* /*
* We need to save copies of both l and r, because we might get a * We need to save copies of both l and r, because we might get a
* partial merge (which modifies both) and then fails to repack * partial merge (which modifies both) and then fails to repack
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment