[CRIU] [PATCH 6/8] compel: Do not loose sign of result in compat syscall
Andrey Vagin
avagin at virtuozzo.com
Sat Nov 4 04:08:07 MSK 2017
Applied, thanks!
On Wed, Nov 01, 2017 at 04:19:23PM +0300, Cyrill Gorcunov wrote:
> 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>
> ---
> compel/arch/x86/src/lib/infect.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/compel/arch/x86/src/lib/infect.c b/compel/arch/x86/src/lib/infect.c
> index 9c919e64ef13..e546ee376d41 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(®s);
> int err;
>
> - if (user_regs_native(®s)) {
> + if (native) {
> user_regs_struct64 *r = ®s.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, ®s, code_int_80);
> }
>
> - *ret = get_user_reg(®s, ax);
> + *ret = native ?
> + (long)get_user_reg(®s, ax) :
> + (int)get_user_reg(®s, ax);
> return err;
> }
>
> @@ -345,6 +348,13 @@ void *remote_mmap(struct parasite_ctl *ctl,
> return NULL;
> }
>
> + /*
> + * For compat tasks the address in foreign process
> + * must lay inside 4 bytes.
> + */
> + if (compat_task)
> + map &= 0xfffffffful;
> +
> return (void *)map;
> }
>
> --
> 2.7.5
>
More information about the CRIU
mailing list