]> www.infradead.org Git - users/jedix/linux-maple.git/commit
maple_tree: Fix mas_spanning_rebalance() on insufficient data
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Fri, 16 Dec 2022 16:44:57 +0000 (11:44 -0500)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Sat, 17 Dec 2022 01:58:24 +0000 (20:58 -0500)
commit3b25b7a45a54601ad49c957aafbaca2c9e403c9b
tree3532887b750f8633672261b2b03fcffa7d814c27
parenteb7081409f94a9a8608593d0fb63a1aa3d6f95d8
maple_tree: Fix mas_spanning_rebalance() on insufficient data

Mike Rapoport contacted me off-list with a regression in running criu.
Periodic tests fail with an RCU stall during execution.  Although rare,
it is possible to hit this with other uses so this patch should be
backported to fix the regression.

An insufficient node was causing an out-of-bounds access on the node in
mas_leaf_max_gap().  The cause was the faulty detection of the new node
being a root node when overwriting many entries at the end of the tree.

Fix the detection of a new root and ensure there is sufficient data
prior to entering the spanning rebalance loop.

Add a testcase to the maple tree test suite for this issue.

Cc: Andrei Vagin <avagin@gmail.com>
Cc: usama.anjum@collabora.com
Reported-by: Mike Rapoport <rppt@kernel.org>
Fixes: 54a611b60590 ("Maple Tree: add new data structure")
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c
lib/test_maple_tree.c