[RH7] ve: add a comment about possible pseudosuper race

Submitted by Pavel Tikhomirov on Oct. 24, 2019, 3:51 p.m.

Details

Message ID 20191024155106.27192-1-ptikhomirov@virtuozzo.com
State New
Series "ve: add a comment about possible pseudosuper race"
Headers show

Commit Message

Pavel Tikhomirov Oct. 24, 2019, 3:51 p.m.
Signed-off-by: Pavel Tikhomirov <ptikhomirov@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;

Comments

Kirill Tkhai Oct. 25, 2019, 9:06 a.m.
On 24.10.2019 18:51, Pavel Tikhomirov wrote:
> 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(+)
> 
> 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;
>