Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
8cf2036e
Commit
8cf2036e
authored
Apr 12, 2024
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: add safety checks in bch2_btree_node_fill()
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
d789e9a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletion
+24
-1
fs/bcachefs/btree_cache.c
fs/bcachefs/btree_cache.c
+24
-1
No files found.
fs/bcachefs/btree_cache.c
View file @
8cf2036e
...
@@ -711,7 +711,30 @@ static noinline struct btree *bch2_btree_node_fill(struct btree_trans *trans,
...
@@ -711,7 +711,30 @@ static noinline struct btree *bch2_btree_node_fill(struct btree_trans *trans,
struct
btree
*
b
;
struct
btree
*
b
;
u32
seq
;
u32
seq
;
BUG_ON
(
level
+
1
>=
BTREE_MAX_DEPTH
);
if
(
unlikely
(
level
>=
BTREE_MAX_DEPTH
))
{
int
ret
=
bch2_fs_topology_error
(
c
,
"attempting to get btree node at level %u, >= max depth %u"
,
level
,
BTREE_MAX_DEPTH
);
return
ERR_PTR
(
ret
);
}
if
(
unlikely
(
!
bkey_is_btree_ptr
(
&
k
->
k
)))
{
struct
printbuf
buf
=
PRINTBUF
;
bch2_bkey_val_to_text
(
&
buf
,
c
,
bkey_i_to_s_c
(
k
));
int
ret
=
bch2_fs_topology_error
(
c
,
"attempting to get btree node with non-btree key %s"
,
buf
.
buf
);
printbuf_exit
(
&
buf
);
return
ERR_PTR
(
ret
);
}
if
(
unlikely
(
k
->
k
.
u64s
>
BKEY_BTREE_PTR_U64s_MAX
))
{
struct
printbuf
buf
=
PRINTBUF
;
bch2_bkey_val_to_text
(
&
buf
,
c
,
bkey_i_to_s_c
(
k
));
int
ret
=
bch2_fs_topology_error
(
c
,
"attempting to get btree node with too big key %s"
,
buf
.
buf
);
printbuf_exit
(
&
buf
);
return
ERR_PTR
(
ret
);
}
/*
/*
* Parent node must be locked, else we could read in a btree node that's
* Parent node must be locked, else we could read in a btree node that's
* been freed:
* been freed:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment