Commit 74cc1abd authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix a buffer overrun

In make_extent_indirect(), we were allocating too small of a buffer for
the new indirect extent.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 224ec3e6
......@@ -138,7 +138,7 @@ static int bch2_make_extent_indirect(struct btree_trans *trans,
/* rewind iter to start of hole, if necessary: */
bch2_btree_iter_set_pos(reflink_iter, bkey_start_pos(k.k));
r_v = bch2_trans_kmalloc(trans, sizeof(__le64) + bkey_val_bytes(&orig->k));
r_v = bch2_trans_kmalloc(trans, sizeof(__le64) + bkey_bytes(&orig->k));
ret = PTR_ERR_OR_ZERO(r_v);
if (ret)
goto err;
......@@ -159,12 +159,6 @@ static int bch2_make_extent_indirect(struct btree_trans *trans,
if (ret)
goto err;
r_p = bch2_trans_kmalloc(trans, sizeof(*r_p));
if (IS_ERR(r_p)) {
ret = PTR_ERR(r_p);
goto err;
}
orig->k.type = KEY_TYPE_reflink_p;
r_p = bkey_i_to_reflink_p(orig);
set_bkey_val_bytes(&r_p->k, sizeof(r_p->v));
......
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