]> git.baikalelectronics.ru Git - kernel.git/commit
drivers/hwspinlock: fix race between radix tree insertion and lookup
authorMatthew Wilcox <willy@linux.intel.com>
Wed, 3 Feb 2016 00:57:55 +0000 (16:57 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 3 Feb 2016 16:28:43 +0000 (08:28 -0800)
commite2ad7362f52d2338e78ee1d64db32045778f98ea
tree4ac7cac19e5d9cfc275a7d99f11ea21026f20275
parentebe4d8cc8028f2c5c48eaba2890adf6737e81a25
drivers/hwspinlock: fix race between radix tree insertion and lookup

of_hwspin_lock_get_id() is protected by the RCU lock, which means that
insertions can occur simultaneously with the lookup.  If the radix tree
transitions from a height of 0, we can see a slot with the indirect_ptr
bit set, which will cause us to at least read random memory, and could
cause other havoc.

Fix this by using the newly introduced radix_tree_iter_retry().

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>
drivers/hwspinlock/hwspinlock_core.c