[RHEL7,COMMIT] mm/tcache: fix rcu_read_lock()/rcu_read_unlock() imbalance

Submitted by Konstantin Khorenko on May 23, 2018, 8:05 a.m.

Details

Message ID 201805230805.w4N85Dmr003376@finist_ce7.work
State New
Series "mm/tcache: fix rcu_read_lock()/rcu_read_unlock() imbalance"
Headers show

Commit Message

Konstantin Khorenko May 23, 2018, 8:05 a.m.
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.1
------>
commit 9a42139df623af5b801c44bc88ffe5093f5349a6
Author: Andrey Ryabinin <aryabinin@virtuozzo.com>
Date:   Wed May 23 11:05:13 2018 +0300

    mm/tcache: fix rcu_read_lock()/rcu_read_unlock() imbalance
    
    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@virtuozzo.com>
    Acked-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 mm/tcache.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

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 @@  static struct page *tcache_detach_page(struct tcache_node *node, pgoff_t index,
 		 * in __tcache_page_tree_delete() fails, and
 		 * we have to repeat the cycle.
 		 */
-		if (!page)
+		if (!page) {
+			rcu_read_lock();
 			goto repeat;
+		}
 	}
 
 	return page;