[RHEL7,COMMIT] ve/cgroup: change resource release order in ve_drop_context

Submitted by Vasily Averin on Oct. 29, 2020, 2:01 p.m.

Details

Message ID 202010291401.09TE141S005818@vz7build.vvs.sw.ru
State New
Series "cgroup: do not use cgroup_mutex in cgroup_show_options"
Headers show

Commit Message

Vasily Averin Oct. 29, 2020, 2:01 p.m.
The commit is pushed to "branch-rh7-3.10.0-1127.18.2.vz7.163.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.18.2.vz7.163.41
------>
commit 6fd72185d1f282076b35b1de3d5435113897b835
Author: Valeriy Vdovin <valeriy.vdovin@virtuozzo.com>
Date:   Thu Oct 29 17:01:04 2020 +0300

    ve/cgroup: change resource release order in ve_drop_context
    
    This fixes 87cb5fdb5b5c77ac617b46a0fe118a7d50a77b1c
    In the mentioned patch in cgroup_show_options ve->ve_ns is checked to
    ensure that ve->root_css_set is usable. But in ve_drop_context
    root_css_set is being released before ve_ns, which is a bug.
    root_css_set will now be set to NULL after ve_ns is released.
    This reordering only affects the described piece of code in
    cgroup_show_options.
    
    https://jira.sw.ru/browse/PSBM-121438
    Signed-off-by: Valeriy Vdovin <valeriy.vdovin@virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 kernel/ve/ve.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index db26cbd4..f61b1fe 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -595,9 +595,6 @@  static void ve_drop_context(struct ve_struct *ve)
 	struct nsproxy *ve_ns = ve->ve_ns;
 	struct net *net = ve->ve_netns;
 
-	put_css_set_taskexit(ve->root_css_set);
-	ve->root_css_set = NULL;
-
 	ve->ve_netns = NULL;
 	put_net(net);
 
@@ -606,6 +603,9 @@  static void ve_drop_context(struct ve_struct *ve)
 	synchronize_rcu();
 	put_nsproxy(ve_ns);
 
+	put_css_set_taskexit(ve->root_css_set);
+	ve->root_css_set = NULL;
+
 	ve_hook_iterate_fini(VE_SHUTDOWN_CHAIN, ve);
 
 	put_cred(ve->init_cred);