[RHEL7,COMMIT] ve: Reorder ve->ve_ns assignment in ve_grab_context()

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


Message ID 202010291403.09TE37cw014332@vz7build.vvs.sw.ru
State New
Series "ve: Reorder ve->ve_ns assignment in ve_grab_context()"
Headers show

Commit Message

Vasily Averin Oct. 29, 2020, 2:03 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 089cdc112a232fa6cbdf59f2fee40b58563c67f1
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Thu Oct 29 17:03:07 2020 +0300

    ve: Reorder ve->ve_ns assignment in ve_grab_context()
    This function must provide guarantees for readers, that
    "ve_ns != NULL" under rcu_read_lock means the rest of context
    (say, ve->init_task) is stable.
    But now order is wrong, and it does not guarantee that. Fix it.
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
 kernel/ve/ve.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 482d658..ff3bf93 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -586,9 +586,10 @@  static void ve_grab_context(struct ve_struct *ve)
 	ve->root_css_set = tsk->cgroups;
 	ve->init_cred = (struct cred *)get_current_cred();
-	rcu_assign_pointer(ve->ve_ns, get_nsproxy(tsk->nsproxy));
 	ve->ve_netns =  get_net(ve->ve_ns->net_ns);
+	rcu_assign_pointer(ve->ve_ns, get_nsproxy(tsk->nsproxy));
 static void ve_drop_context(struct ve_struct *ve)