vdso: Correctly track vdso position without vvar

Submitted by Dmitry Safonov on Aug. 10, 2019, 1:33 a.m.

Details

Message ID 20190810013329.15241-1-dima@arista.com
State Accepted
Series "vdso: Correctly track vdso position without vvar"
Headers show

Commit Message

Dmitry Safonov Aug. 10, 2019, 1:33 a.m.
If vvar is absent vdso_before_vvar is initialized by "false".
Which means that the check that supposed to track vdso/vvar pair went
into wrong brackets. In result it broke CRIU on kernels that don't have
vvar mapping.

Simpilfy the code by moving the check for VVAR_BAD_SIZE outside of
conditional for vdso_before_vvar.

Reported-by: Cyrill Gorcunov <gorcunov@gmail.com>
Fixes: 0918c7667647 ("vdso/restorer: Always track vdso/vvar positions in
vdso_maps_rt")
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 criu/pie/restorer.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
index 6f8f1ae543ae..390c0e1a9a03 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -1293,13 +1293,16 @@  static int map_vdso(struct task_restore_args *args, bool compatible)
 		return err;
 	}
 
+	/* kernel may provide only vdso */
+	if (rt->sym.vvar_size == VVAR_BAD_SIZE) {
+		rt->vdso_start = args->vdso_rt_parked_at;
+		rt->vvar_start = VVAR_BAD_ADDR;
+		return 0;
+	}
+
 	if (rt->sym.vdso_before_vvar) {
 		rt->vdso_start = args->vdso_rt_parked_at;
-		/* kernel may provide only vdso */
-		if (rt->sym.vvar_size != VVAR_BAD_SIZE)
-			rt->vvar_start = rt->vdso_start + rt->sym.vdso_size;
-		else
-			rt->vvar_start = VVAR_BAD_ADDR;
+		rt->vvar_start = rt->vdso_start + rt->sym.vdso_size;
 	} else {
 		rt->vvar_start = args->vdso_rt_parked_at;
 		rt->vdso_start = rt->vvar_start + rt->sym.vvar_size;

Comments

Cyrill Gorcunov Aug. 12, 2019, 3:31 p.m.
On Sat, Aug 10, 2019 at 02:33:29AM +0100, Dmitry Safonov wrote:
> If vvar is absent vdso_before_vvar is initialized by "false".
> Which means that the check that supposed to track vdso/vvar pair went
> into wrong brackets. In result it broke CRIU on kernels that don't have
> vvar mapping.
> 
> Simpilfy the code by moving the check for VVAR_BAD_SIZE outside of
> conditional for vdso_before_vvar.
> 
> Reported-by: Cyrill Gorcunov <gorcunov@gmail.com>
> Fixes: 0918c7667647 ("vdso/restorer: Always track vdso/vvar positions in
> vdso_maps_rt")
> Signed-off-by: Dmitry Safonov <dima@arista.com>

Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Tested-by: Cyrill Gorcunov <gorcunov@gmail.com>
Andrei Vagin Aug. 13, 2019, 2:45 p.m.
Applied, thanks!

On Sat, Aug 10, 2019 at 02:33:29AM +0100, Dmitry Safonov wrote:
> If vvar is absent vdso_before_vvar is initialized by "false".
> Which means that the check that supposed to track vdso/vvar pair went
> into wrong brackets. In result it broke CRIU on kernels that don't have
> vvar mapping.
> 
> Simpilfy the code by moving the check for VVAR_BAD_SIZE outside of
> conditional for vdso_before_vvar.
> 
> Reported-by: Cyrill Gorcunov <gorcunov@gmail.com>
> Fixes: 0918c7667647 ("vdso/restorer: Always track vdso/vvar positions in
> vdso_maps_rt")
> Signed-off-by: Dmitry Safonov <dima@arista.com>
> ---
>  criu/pie/restorer.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
> index 6f8f1ae543ae..390c0e1a9a03 100644
> --- a/criu/pie/restorer.c
> +++ b/criu/pie/restorer.c
> @@ -1293,13 +1293,16 @@ static int map_vdso(struct task_restore_args *args, bool compatible)
>  		return err;
>  	}
>  
> +	/* kernel may provide only vdso */
> +	if (rt->sym.vvar_size == VVAR_BAD_SIZE) {
> +		rt->vdso_start = args->vdso_rt_parked_at;
> +		rt->vvar_start = VVAR_BAD_ADDR;
> +		return 0;
> +	}
> +
>  	if (rt->sym.vdso_before_vvar) {
>  		rt->vdso_start = args->vdso_rt_parked_at;
> -		/* kernel may provide only vdso */
> -		if (rt->sym.vvar_size != VVAR_BAD_SIZE)
> -			rt->vvar_start = rt->vdso_start + rt->sym.vdso_size;
> -		else
> -			rt->vvar_start = VVAR_BAD_ADDR;
> +		rt->vvar_start = rt->vdso_start + rt->sym.vdso_size;
>  	} else {
>  		rt->vvar_start = args->vdso_rt_parked_at;
>  		rt->vdso_start = rt->vvar_start + rt->sym.vvar_size;
> -- 
> 2.22.0
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu