diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-10-18 11:32:06 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:14 -0400 |
commit | 70d61a7036c8d046889a4bf4eda504a6a56b2642 (patch) | |
tree | ec784d95c718abf9ee47e36432621d7d0c3bbe46 /fs/bcachefs/reflink.c | |
parent | bd547c8acb1aa76ceab1987109ac6ceae698fcc9 (diff) | |
download | linux-stable-70d61a7036c8d046889a4bf4eda504a6a56b2642.tar.gz linux-stable-70d61a7036c8d046889a4bf4eda504a6a56b2642.tar.bz2 linux-stable-70d61a7036c8d046889a4bf4eda504a6a56b2642.zip |
bcachefs: Zero out reflink_p val in bch2_make_extent_indirect()
This bug was only discovered when we started using the 2nd word in the
val, which should have been zeroed out as those fields had never been
used before - ouch.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/reflink.c')
-rw-r--r-- | fs/bcachefs/reflink.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/bcachefs/reflink.c b/fs/bcachefs/reflink.c index 92ff609453b8..c63c95fc49b1 100644 --- a/fs/bcachefs/reflink.c +++ b/fs/bcachefs/reflink.c @@ -166,9 +166,15 @@ static int bch2_make_extent_indirect(struct btree_trans *trans, if (ret) goto err; + /* + * orig is in a bkey_buf which statically allocates 5 64s for the val, + * so we know it will be big enough: + */ 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)); + memset(&r_p->v, 0, sizeof(r_p->v)); + r_p->v.idx = cpu_to_le64(bkey_start_offset(&r_v->k)); ret = bch2_trans_update(trans, extent_iter, &r_p->k_i, 0); |