Skip to contentSkip to conversation

maple_tree: Fix mas_alloc_nodes()

PATCH In review Liam Howlett 2 participants 2 messages Aug 2, 2022 – Aug 6, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 maple_tree: Fix mas_alloc_nodes()

Use MAPLE_ALLOC_SLOTS, which differs on 32bit. This was causing an out of bounds issue on 32bit bulk allocations

Fixes 06b152b7980a (Maple Tree: add new data structure)
---
 lib/maple_tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/maple_tree.c +1 -1
index 4e41f3394114..032e7bb0d44f 100644
@@ -1242,7 +1242,7 @@ static inline void mas_alloc_nodes(struct ma_state *mas, gfp_t gfp)
 
 	node = mas->alloc;
 	while (requested) {
-		max_req = MAPLE_NODE_SLOTS - 1;
+		max_req = MAPLE_ALLOC_SLOTS;
 		if (node->slot[0]) {
 			unsigned int offset = node->node_count + 1;
 
Signature · 1 line
2.35.1
Tested-by on v1 1/1
#1 lore raw

02.08.2022 22:36, Liam Howlett пишет:

Quoted 14 lines

Use MAPLE_ALLOC_SLOTS, which differs on 32bit. This was causing an out of bounds issue on 32bit bulk allocations

Fixes 06b152b7980a (Maple Tree: add new data structure)
---
 lib/maple_tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/maple_tree.c +0 -0
index 4e41f3394114..032e7bb0d44f 100644

lib/maple_tree.c static inline void mas_alloc_nodes(struct ma_state *mas, gfp_t gfp) · line 1248

Quoted 8 lines
lib/maple_tree.c +1 -1
@@ -1242,7 +1242,7 @@ static inline void mas_alloc_nodes(struct ma_state *mas, gfp_t gfp)
 
 	node = mas->alloc;
 	while (requested) {
-		max_req = MAPLE_NODE_SLOTS - 1;
+		max_req = MAPLE_ALLOC_SLOTS;
 		if (node->slot[0]) {
 			unsigned int offset = node->node_count + 1;
 

Hello Liam,

This fixed the bug, thank you!