maple_tree: add RCU lock checking to rcu callback functions
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 11 Apr 2023 15:10:54 +0000 (11:10 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Apr 2023 14:55:40 +0000 (16:55 +0200)
commit9b6627bc36aaf426f11b3531aa26d48513c68cbf
treed2b6dc89fe24062e92d3fc74ce712f6136e24cd4
parenta29025a1b61cfe48d13dbc23e19b07507ef44054
maple_tree: add RCU lock checking to rcu callback functions

commit 790e1fa86b340c2bd4a327e01c161f7a1ad885f6 upstream.

Dereferencing RCU objects within the RCU callback without the RCU check
has caused lockdep to complain.  Fix the RCU dereferencing by using the
RCU callback lock to ensure the operation is safe.

Also stop creating a new lock to use for dereferencing during destruction
of the tree or subtree.  Instead, pass through a pointer to the tree that
has the lock that is held for RCU dereferencing checking.  It also does
not make sense to use the maple state in the freeing scenario as the tree
walk is a special case where the tree no longer has the normal encodings
and parent pointers.

Link: https://lkml.kernel.org/r/20230227173632.3292573-8-surenb@google.com
Fixes: 54a611b60590 ("Maple Tree: add new data structure")
Cc: stable@vger.kernel.org
Reported-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
lib/maple_tree.c