summaryrefslogtreecommitdiff
path: root/fs/bcachefs/bkey_methods.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-06-10 03:32:54 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:08:23 +0300
commit66b095b008ea6526c660fbecfacbd970416f971e (patch)
treec1530186c4335a86b66dcdca95677d0093dfc18d /fs/bcachefs/bkey_methods.c
parent9146b8ee03fb8a716e6a88d68b8e9074594966bb (diff)
downloadlinux-66b095b008ea6526c660fbecfacbd970416f971e.tar.xz
bcachefs: Don't allow bkey vals that are too big in extents btree
Make sure we don't overflow BKEY_PADDED keys Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/bkey_methods.c')
-rw-r--r--fs/bcachefs/bkey_methods.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/bcachefs/bkey_methods.c b/fs/bcachefs/bkey_methods.c
index 547f5b301ad4..09ee958c5568 100644
--- a/fs/bcachefs/bkey_methods.c
+++ b/fs/bcachefs/bkey_methods.c
@@ -82,6 +82,11 @@ const char *__bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
if (k.k->u64s < BKEY_U64s)
return "u64s too small";
+ if ((btree_node_type_is_extents(type) ||
+ type == BKEY_TYPE_BTREE) &&
+ bkey_val_u64s(k.k) > BKEY_EXTENT_VAL_U64s_MAX)
+ return "value too big";
+
if (btree_node_type_is_extents(type)) {
if ((k.k->size == 0) != bkey_deleted(k.k))
return "bad size field";