mirror of
https://github.com/torvalds/linux.git
synced 2026-06-06 05:27:07 +02:00
bcachefs: Validate that we read the correct btree node
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
a9310ab06c
commit
f36dff2885
|
|
@ -736,6 +736,17 @@ static int validate_bset(struct bch_fs *c, struct btree *b,
|
|||
struct btree_node *bn =
|
||||
container_of(i, struct btree_node, keys);
|
||||
/* These indicate that we read the wrong btree node: */
|
||||
|
||||
if (b->key.k.type == KEY_TYPE_btree_ptr_v2) {
|
||||
struct bch_btree_ptr_v2 *bp =
|
||||
&bkey_i_to_btree_ptr_v2(&b->key)->v;
|
||||
|
||||
/* XXX endianness */
|
||||
btree_err_on(bp->seq != bn->keys.seq,
|
||||
BTREE_ERR_MUST_RETRY, c, b, NULL,
|
||||
"incorrect sequence number (wrong btree node)");
|
||||
}
|
||||
|
||||
btree_err_on(BTREE_NODE_ID(bn) != b->c.btree_id,
|
||||
BTREE_ERR_MUST_RETRY, c, b, i,
|
||||
"incorrect btree id");
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user