diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-04-11 21:30:43 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-04-13 22:48:16 -0400 |
commit | 031ad9e7dbd18c63e671fc4d98be3082189b8a63 (patch) | |
tree | dea635b27987a38034a6248df19875fe018040cf /fs/bcachefs/bkey.h | |
parent | 58caa786f1c02fd84919fb6db9eaecb22e8f7983 (diff) | |
download | lwn-031ad9e7dbd18c63e671fc4d98be3082189b8a63.tar.gz lwn-031ad9e7dbd18c63e671fc4d98be3082189b8a63.zip |
bcachefs: Check for packed bkeys that are too big
add missing validation; fixes assertion pop in bkey unpack
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, 6 insertions, 0 deletions
diff --git a/fs/bcachefs/bkey.h b/fs/bcachefs/bkey.h index cf23ff47bed8..3a45d128f608 100644 --- a/fs/bcachefs/bkey.h +++ b/fs/bcachefs/bkey.h @@ -314,6 +314,12 @@ static inline unsigned bkeyp_key_u64s(const struct bkey_format *format, return bkey_packed(k) ? format->key_u64s : BKEY_U64s; } +static inline bool bkeyp_u64s_valid(const struct bkey_format *f, + const struct bkey_packed *k) +{ + return ((unsigned) k->u64s - bkeyp_key_u64s(f, k) <= U8_MAX - BKEY_U64s); +} + static inline unsigned bkeyp_key_bytes(const struct bkey_format *format, const struct bkey_packed *k) { |