[RH7] ve: Reorder ve->ve_ns assignment in ve_grab_context()

Submitted by Kirill Tkhai on Oct. 29, 2020, 11:34 a.m.

Details

Message ID 160397120820.901411.10282626598028535392.stgit@localhost.localdomain
State New
Series "ve: Reorder ve->ve_ns assignment in ve_grab_context()"
Headers show

Commit Message

Kirill Tkhai Oct. 29, 2020, 11:34 a.m.
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 db26cbd41d3f..9dce4c245659 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -585,9 +585,10 @@  static void ve_grab_context(struct ve_struct *ve)
 	ve->root_css_set = tsk->cgroups;
 	get_css_set(ve->root_css_set);
 	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);
 	synchronize_rcu();
+
+	rcu_assign_pointer(ve->ve_ns, get_nsproxy(tsk->nsproxy));
 }
 
 static void ve_drop_context(struct ve_struct *ve)