Commit 0151d10a authored by Piotr Zalewski's avatar Piotr Zalewski Committed by Kent Overstreet

bcachefs: add check for btree id against max in try read node

Add check for read node's btree_id against BTREE_ID_NR_MAX in
try_read_btree_node to prevent triggering EBUG_ON condition in
bch2_btree_id_root[1].

[1] https://syzkaller.appspot.com/bug?extid=cf7b2215b5d70600ec00

Reported-by: syzbot+cf7b2215b5d70600ec00@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=cf7b2215b5d70600ec00
Fixes: 4409b808 ("bcachefs: Repair pass for scanning for btree nodes")
Signed-off-by: default avatarPiotr Zalewski <pZ010001011111@proton.me>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 19773ec9
...@@ -171,6 +171,9 @@ static void try_read_btree_node(struct find_btree_nodes *f, struct bch_dev *ca, ...@@ -171,6 +171,9 @@ static void try_read_btree_node(struct find_btree_nodes *f, struct bch_dev *ca,
if (BTREE_NODE_LEVEL(bn) >= BTREE_MAX_DEPTH) if (BTREE_NODE_LEVEL(bn) >= BTREE_MAX_DEPTH)
return; return;
if (BTREE_NODE_ID(bn) >= BTREE_ID_NR_MAX)
return;
rcu_read_lock(); rcu_read_lock();
struct found_btree_node n = { struct found_btree_node n = {
.btree_id = BTREE_NODE_ID(bn), .btree_id = BTREE_NODE_ID(bn),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment