Commit 2e16cc1e authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Andrei Vagin

compel: Do not loose sign of result in compat syscall

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: 's avatarCyrill Gorcunov <gorcunov@virtuozzo.com>
Reviewed-by: 's avatarDmitry Safonov <dima@arista.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent fc21d6fb
......@@ -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;
}
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment