]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
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 15:02:59 +0000 (17:02 +0200)
commita4ea73e99e93d9910a5f9818d4aa9fb40f244bdc
treeae5246c3ff3a0a836440090e0a8b8cf3cc6a1523
parent0644026e7717fc8ebe37ff49111b1a5081c5bfae
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