projects
/
platform
/
kernel
/
linux-starfive.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f41e9e6
)
maple_tree: reduce user error potential
author
Liam R. Howlett
<Liam.Howlett@Oracle.com>
Tue, 11 Apr 2023 15:10:44 +0000
(11:10 -0400)
committer
Greg Kroah-Hartman
<gregkh@linuxfoundation.org>
Thu, 13 Apr 2023 14:55:38 +0000
(16:55 +0200)
commit
50e81c82ad947045c7ed26ddc9acb17276b653b6
upstream.
When iterating, a user may operate on the tree and cause the maple state
to be altered and left in an unintuitive state. Detect this scenario and
correct it by setting to the limit and invalidating the state.
Link:
https://lkml.kernel.org/r/20230120162650.984577-4-Liam.Howlett@oracle.com
Cc: <Stable@vger.kernel.org>
Fixes:
54a611b60590
("Maple Tree: add new data structure")
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
lib/maple_tree.c
patch
|
blob
|
history
diff --git
a/lib/maple_tree.c
b/lib/maple_tree.c
index
f8e1e85
..
360b4bb
100644
(file)
--- a/
lib/maple_tree.c
+++ b/
lib/maple_tree.c
@@
-4731,6
+4731,11
@@
static inline void *mas_next_entry(struct ma_state *mas, unsigned long limit)
unsigned long last;
enum maple_type mt;
+ if (mas->index > limit) {
+ mas->index = mas->last = limit;
+ mas_pause(mas);
+ return NULL;
+ }
last = mas->last;
retry:
offset = mas->offset;
@@
-4837,6
+4842,11
@@
static inline void *mas_prev_entry(struct ma_state *mas, unsigned long min)
{
void *entry;
+ if (mas->index < min) {
+ mas->index = mas->last = min;
+ mas_pause(mas);
+ return NULL;
+ }
retry:
while (likely(!mas_is_none(mas))) {
entry = mas_prev_nentry(mas, min, mas->index);