Skip to contentSkip to conversation

Patch "drivers/hwspinlock: fix race between radix tree insertion and lookup" has been added to the 4.4-stable tree

PATCH [email protected] 1 participant 1 message Feb 24, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

drivers/hwspinlock: fix race between radix tree insertion and lookup

to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
drivers-hwspinlock-fix-race-between-radix-tree-insertion-and-lookup.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From c6400ba7e13a41539342f1b6e1f9e78419cb0148 Mon Sep 17 00:00:00 2001

From: Matthew Wilcox <[email protected]>
Date: Tue, 2 Feb 2016 16:57:55 -0800
Subject: drivers/hwspinlock: fix race between radix tree insertion and lookup

From: Matthew Wilcox <[email protected]>

commit c6400ba7e13a41539342f1b6e1f9e78419cb0148 upstream.

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().

---
 drivers/hwspinlock/hwspinlock_core.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/hwspinlock/hwspinlock_core.c +4 -0
@@ -313,6 +313,10 @@ int of_hwspin_lock_get_id(struct device_
 		hwlock = radix_tree_deref_slot(slot);
 		if (unlikely(!hwlock))
 			continue;
+		if (radix_tree_is_indirect_ptr(hwlock)) {
+			slot = radix_tree_iter_retry(&iter);
+			continue;
+		}
 
 		if (hwlock->bank->dev->of_node == args.np) {
 			ret = 0;

Patches currently in stable-queue which might be from [email protected] are

queue-4.4/radix-tree-fix-oops-after-radix_tree_iter_retry.patch queue-4.4/drivers-hwspinlock-fix-race-between-radix-tree-insertion-and-lookup.patch queue-4.4/radix-tree-fix-race-in-gang-lookup.patch queue-4.4/devm_memremap_release-fix-memremap-d-addr-handling.patch