diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-06-12 19:51:15 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-06-19 18:27:23 -0400 |
commit | d47df4f616d523b4ef832d03ec28b2e6d838067b (patch) | |
tree | 9765c12aaf7cf67f02958f8822d4f686c850bce7 /fs/bcachefs/bkey.c | |
parent | f770a6e9a3d7a90f77863b51325614f37a57fef5 (diff) |
bcachefs: Fix array-index-out-of-bounds
We use 0 size arrays as markers, but ubsan doesn't know that - cast them
to a pointer to fix the splat.
Also, make sure this code gets tested a bit more.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/bkey.c')
-rw-r--r-- | fs/bcachefs/bkey.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/bcachefs/bkey.c b/fs/bcachefs/bkey.c index f46978e5cb7c..94a1d1982fa8 100644 --- a/fs/bcachefs/bkey.c +++ b/fs/bcachefs/bkey.c @@ -1064,7 +1064,7 @@ void bch2_bkey_swab_key(const struct bkey_format *_f, struct bkey_packed *k) { const struct bkey_format *f = bkey_packed(k) ? _f : &bch2_bkey_format_current; u8 *l = k->key_start; - u8 *h = (u8 *) (k->_data + f->key_u64s) - 1; + u8 *h = (u8 *) ((u64 *) k->_data + f->key_u64s) - 1; while (l < h) { swap(*l, *h); |