[Devel] [PATCH rh7] mm/tcache: fix rcu_read_lock()/rcu_read_unlock() imbalance

Andrey Ryabinin aryabinin at virtuozzo.com
Tue May 22 11:56:07 MSK 2018


tcache_detach_page()

	rcu_read_lock();
repeat:
	.....
	rcu_read_unlock();

	if (page) {
		...
		page = tcache_page_tree_delete(node, index, page);
		....
		if (!page)
			goto repeat; // <- will cause rcu_read_unlock() without lock

Take rcu lock before the last 'goto repeat;' in tcache_detach_page().

https://jira.sw.ru/browse/PSBM-81731
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 mm/tcache.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/tcache.c b/mm/tcache.c
index 02fde409e691..9fc7cbf1c40b 100644
--- a/mm/tcache.c
+++ b/mm/tcache.c
@@ -864,8 +864,10 @@ out:
 		 * in __tcache_page_tree_delete() fails, and
 		 * we have to repeat the cycle.
 		 */
-		if (!page)
+		if (!page) {
+			rcu_read_lock();
 			goto repeat;
+		}
 	}
 
 	return page;
-- 
2.16.1



More information about the Devel mailing list