The patch titled Subject: maple_tree: fix potential out of range offset on mas_next()/mas_prev() has been added to the -mm mm-unstable branch. Its filename is maple-tree-add-new-data-structure-fix-4.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/maple-tree-add-new-data-structure-fix-4.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Liam Howlett <liam.howlett@xxxxxxxxxx> Subject: maple_tree: fix potential out of range offset on mas_next()/mas_prev() Date: Thu, 19 May 2022 15:03:37 +0000 When going between next/prev, be more careful to stay within the nodes range. Link: https://lkml.kernel.org/r/20220519150304.1289636-1-Liam.Howlett@xxxxxxxxxx Signed-off-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- lib/maple_tree.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/lib/maple_tree.c~maple-tree-add-new-data-structure-fix-4 +++ a/lib/maple_tree.c @@ -4628,8 +4628,10 @@ retry: node = mas_mn(mas); mt = mte_node_type(mas->node); mas->offset++; - if (unlikely(mas->offset >= mt_slots[mt])) + if (unlikely(mas->offset >= mt_slots[mt])) { + mas->offset = mt_slots[mt] - 1; goto next_node; + } while (!mas_is_none(mas)) { entry = mas_next_nentry(mas, node, limit, mt); @@ -4687,6 +4689,9 @@ retry: mn = mas_mn(mas); mt = mte_node_type(mas->node); offset = mas->offset - 1; + if (offset >= mt_slots[mt]) + offset = mt_slots[mt] - 1; + slots = ma_slots(mn, mt); pivots = ma_pivots(mn, mt); if (offset == mt_pivots[mt]) _ Patches currently in -mm which might be from liam.howlett@xxxxxxxxxx are maple-tree-add-new-data-structure-fix.patch maple-tree-add-new-data-structure-fix-2.patch maple-tree-add-new-data-structure-fix-3.patch maple-tree-add-new-data-structure-fix-4.patch lib-test_maple_tree-add-testing-for-maple-tree-fix.patch mm-start-tracking-vmas-with-maple-tree-fix-2.patch mm-remove-the-vma-linked-list-fix.patch