Skip to content

Commit 5c59080

Browse files
howlettakpm00
authored andcommitted
maple_tree: add mas_is_active() to detect in-tree walks
Patch series "maple_tree: Fix mas_prev() state regression". Pedro Falcato retported an mprotect regression [1] which was bisected back to the iterator changes for maple tree. Root cause analysis showed the mas_prev() running off the end of the VMA space (previous from 0) followed by mas_find(), would skip the first value. This patchset introduces maple state underflow/overflow so the sequence of calls on the maple state will return what the user expects. Users who encounter this bug may see mprotect(), userfaultfd_register(), and mlock() fail on VMAs mapped with address 0. This patch (of 2): Instead of constantly checking each possibility of the maple state, create a fast path that will skip over checking unlikely states. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Liam R. Howlett <[email protected]> Cc: Pedro Falcato <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 7ee29fa commit 5c59080

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

include/linux/maple_tree.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,15 @@ static inline bool mas_is_paused(const struct ma_state *mas)
511511
return mas->node == MAS_PAUSE;
512512
}
513513

514+
/* Check if the mas is pointing to a node or not */
515+
static inline bool mas_is_active(struct ma_state *mas)
516+
{
517+
if ((unsigned long)mas->node >= MAPLE_RESERVED_RANGE)
518+
return true;
519+
520+
return false;
521+
}
522+
514523
/**
515524
* mas_reset() - Reset a Maple Tree operation state.
516525
* @mas: Maple Tree operation state.

0 commit comments

Comments
 (0)