[CRIU] [PATCH] compel: Do not loose sign of result in compat syscall

Dmitry Safonov 0x7f454c46 at gmail.com
Tue Oct 31 15:11:59 MSK 2017


2017-10-30 14:57 GMT+00:00 Cyrill Gorcunov <gorcunov at openvz.org>:
> From: Cyrill Gorcunov <gorcunov at virtuozzo.com>
>
> Regs are present in unsigned format so convert them
> into signed first to provide results.
>
> In particular if memfd_create syscall failed we won't
> notice -ENOMEM error but rather treat it as unsigned
> hex value
>
>  | (05.303002) Putting parasite blob into 0x7f1c6ffe0000->0xfffffff4
>  | (05.303234) Putting tsock into pid 42773
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>

Looks like a right thing to me,
Reviewed-by: Dmitry Safonov <dima at arista.com>

> ---
>
> Travis is running by now https://travis-ci.org/cyrillos/criu/builds/294898355
>
>  compel/arch/x86/src/lib/infect.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/compel/arch/x86/src/lib/infect.c b/compel/arch/x86/src/lib/infect.c
> index 9c919e64ef13..ac5f8b05e768 100644
> --- a/compel/arch/x86/src/lib/infect.c
> +++ b/compel/arch/x86/src/lib/infect.c
> @@ -293,9 +293,10 @@ int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret,
>                 unsigned long arg6)
>  {
>         user_regs_struct_t regs = ctl->orig.regs;
> +       bool native = user_regs_native(&regs);
>         int err;
>
> -       if (user_regs_native(&regs)) {
> +       if (native) {
>                 user_regs_struct64 *r = &regs.native;
>
>                 r->ax  = (uint64_t)nr;
> @@ -321,7 +322,9 @@ int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret,
>                 err = compel_execute_syscall(ctl, &regs, code_int_80);
>         }
>
> -       *ret = get_user_reg(&regs, ax);
> +       *ret = native ?
> +               (long)get_user_reg(&regs, ax) :
> +               (int)get_user_reg(&regs, ax);
>         return err;
>  }
>
> --
> 2.7.5
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu



-- 
             Dmitry


More information about the CRIU mailing list