mirror of
https://github.com/torvalds/linux.git
synced 2026-05-22 22:22:08 +02:00
bcachefs: Fix dup/misordered check in btree node read
We were checking for out of order keys, but not duplicate keys. Reported-by: syzbot+dedbd67513939979f84f@syzkaller.appspotmail.com Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
1415265480
commit
75eabea698
|
|
@ -857,6 +857,14 @@ static bool bkey_packed_valid(struct bch_fs *c, struct btree *b,
|
|||
return !__bch2_bkey_validate(c, u.s_c, btree_node_type(b), BCH_VALIDATE_silent);
|
||||
}
|
||||
|
||||
static inline int btree_node_read_bkey_cmp(const struct btree *b,
|
||||
const struct bkey_packed *l,
|
||||
const struct bkey_packed *r)
|
||||
{
|
||||
return bch2_bkey_cmp_packed(b, l, r)
|
||||
?: (int) bkey_deleted(r) - (int) bkey_deleted(l);
|
||||
}
|
||||
|
||||
static int validate_bset_keys(struct bch_fs *c, struct btree *b,
|
||||
struct bset *i, int write,
|
||||
bool have_retry, bool *saw_error)
|
||||
|
|
@ -917,7 +925,7 @@ static int validate_bset_keys(struct bch_fs *c, struct btree *b,
|
|||
BSET_BIG_ENDIAN(i), write,
|
||||
&b->format, k);
|
||||
|
||||
if (prev && bkey_iter_cmp(b, prev, k) > 0) {
|
||||
if (prev && btree_node_read_bkey_cmp(b, prev, k) >= 0) {
|
||||
struct bkey up = bkey_unpack_key(b, prev);
|
||||
|
||||
printbuf_reset(&buf);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user