]> www.infradead.org Git - users/jedix/linux-maple.git/commit
radix-tree: fix race in gang lookup
authorMatthew Wilcox <willy@linux.intel.com>
Wed, 3 Feb 2016 00:57:52 +0000 (16:57 -0800)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 26 May 2016 22:44:43 +0000 (15:44 -0700)
commit458c08de6d2e6799e7f0393179f085948a91e15e
treee4128b135f3f895a44e82c533419b9f54ee6cbb8
parent70e93457041c6380fd0d4a35c90d5aca0447a8cc
radix-tree: fix race in gang lookup

Orabug: 23330811

[ Upstream commit 46437f9a554fbe3e110580ca08ab703b59f2f95a ]

If the indirect_ptr bit is set on a slot, that indicates we need to redo
the lookup.  Introduce a new function radix_tree_iter_retry() which
forces the loop to retry the lookup by setting 'slot' to NULL and
turning the iterator back to point at the problematic entry.

This is a pretty rare problem to hit at the moment; the lookup has to
race with a grow of the radix tree from a height of 0.  The consequences
of hitting this race are that gang lookup could return a pointer to a
radix_tree_node instead of a pointer to whatever the user had inserted
in the tree.

Fixes: cebbd29e1c2f ("radix-tree: rewrite gang lookup using iterator")
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Ohad Ben-Cohen <ohad@wizery.com>
Cc: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
(cherry picked from commit cd3c40afce6cd0209432e6690e60c2156a27c68d)

Signed-off-by: Dan Duval <dan.duval@oracle.com>
include/linux/radix-tree.h
lib/radix-tree.c