diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-09-09 20:10:11 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:10:12 -0400 |
commit | 5cfd69775eb5460ef78bb5034a37eb0dc52ab65d (patch) | |
tree | 26a5e49f14d153acbf243df39a75e38ffdc9f3d6 /fs/bcachefs/bkey.h | |
parent | a9a7bbab1469f0c427f90c309720c543e37ab110 (diff) | |
download | linux-5cfd69775eb5460ef78bb5034a37eb0dc52ab65d.tar.gz linux-5cfd69775eb5460ef78bb5034a37eb0dc52ab65d.tar.bz2 linux-5cfd69775eb5460ef78bb5034a37eb0dc52ab65d.zip |
bcachefs: Array bounds fixes
It's no longer legal to use a zero size array as a flexible array
member - this causes UBSAN to complain.
This patch switches our zero size arrays to normal flexible array
members when possible, and inserts casts in other places (e.g. where we
use the zero size array as a marker partway through an array).
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/bkey.h')
-rw-r--r-- | fs/bcachefs/bkey.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/bcachefs/bkey.h b/fs/bcachefs/bkey.h index 51969a46265e..518450209236 100644 --- a/fs/bcachefs/bkey.h +++ b/fs/bcachefs/bkey.h @@ -52,7 +52,7 @@ struct bkey_s { static inline struct bkey_i *bkey_next(struct bkey_i *k) { - return (struct bkey_i *) (k->_data + k->k.u64s); + return (struct bkey_i *) ((u64 *) k->_data + k->k.u64s); } #define bkey_val_u64s(_k) ((_k)->u64s - BKEY_U64s) @@ -397,7 +397,7 @@ static inline void set_bkeyp_val_u64s(const struct bkey_format *format, } #define bkeyp_val(_format, _k) \ - ((struct bch_val *) ((_k)->_data + bkeyp_key_u64s(_format, _k))) + ((struct bch_val *) ((u64 *) (_k)->_data + bkeyp_key_u64s(_format, _k))) extern const struct bkey_format bch2_bkey_format_current; @@ -732,7 +732,7 @@ static inline unsigned high_word_offset(const struct bkey_format *f) #error edit for your odd byteorder. #endif -#define high_word(f, k) ((k)->_data + high_word_offset(f)) +#define high_word(f, k) ((u64 *) (k)->_data + high_word_offset(f)) #define next_word(p) nth_word(p, 1) #define prev_word(p) nth_word(p, -1) |