[RHEL7,COMMIT] ve: add a comment about possible pseudosuper race

Submitted by Konstantin Khorenko on Oct. 25, 2019, 10:40 a.m.

Details

Message ID 201910251040.x9PAeuId005981@finist-ce7.sw.ru
State New
Series "ve: add a comment about possible pseudosuper race"
Headers show

Commit Message

Konstantin Khorenko Oct. 25, 2019, 10:40 a.m.
The commit is pushed to "branch-rh7-3.10.0-1062.1.2.vz7.114.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1062.1.2.vz7.114.9
------>
commit 7606beb9a2c57b70e2d84e2022c91cb41d6be31a
Author: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Date:   Fri Oct 25 13:40:56 2019 +0300

    ve: add a comment about possible pseudosuper race
    
    Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 kernel/ve/ve.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Patch hide | download patch | download mbox

diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 4565f39c8874..ad3a698ba9de 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1345,6 +1345,18 @@  static int ve_write_pseudosuper(struct cgroup *cg,
 		return -EBUSY;
 	}
 	ve->is_pseudosuper = value;
+	/*
+	 * In criu we do unset pseudosuper on ve cgroup just before doing
+	 * ptrace(PTRACE_DETACH) to release restored process, what if one of
+	 * them will see pseudosuper flag still set to 1?
+	 *
+	 * To be 100% sure that these will never happen we need to call
+	 * synchronize_sched_expedited(); here to make cross cpu memory
+	 * barrier.
+	 *
+	 * For now we rely on userspace that ptrace from criu will do wake-up
+	 * on CT tasks which should imply memory barrier.
+	 */
 	up_write(&ve->op_sem);
 
 	return 0;