Skip to content

Commit 2bb9600

Browse files
author
Kent Overstreet
committed
bcachefs: Guard against unknown k.k->type in __bkey_invalid()
For forwards compatibility we have to allow unknown key types, and only run the checks that make sense against them. Fix a missing guard on k.k->type being known. Reported-by: syzbot+ae4dc916da3ce51f284f@syzkaller.appspotmail.com Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent f390552 commit 2bb9600

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

fs/bcachefs/bkey_methods.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ int __bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
171171
if (type >= BKEY_TYPE_NR)
172172
return 0;
173173

174-
bkey_fsck_err_on((type == BKEY_TYPE_btree ||
175-
(flags & BKEY_INVALID_COMMIT)) &&
174+
bkey_fsck_err_on(k.k->type < KEY_TYPE_MAX &&
175+
(type == BKEY_TYPE_btree || (flags & BKEY_INVALID_COMMIT)) &&
176176
!(bch2_key_types_allowed[type] & BIT_ULL(k.k->type)), c, err,
177177
bkey_invalid_type_for_btree,
178178
"invalid key type for btree %s (%s)",

0 commit comments

Comments
 (0)