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

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


2017-10-31 11:53 GMT+00:00 Cyrill Gorcunov <gorcunov at virtuozzo.com>:
> On Tue, Oct 31, 2017 at 11:47:32AM +0000, Dmitry Safonov wrote:
>> > From: Cyrill Gorcunov <gorcunov at virtuozzo.com>
>> > Date: Mon, 30 Oct 2017 23:16:58 +0300
>> > Subject: [PATCH] compel: x86,compat -- Make sure mmap fits compat task size
>> >
>> > In addition to
>> >
>> >  | commit 702d51315bdd337b9ab3d32c952bb8a150440d45
>> >  | Author: Cyrill Gorcunov <gorcunov at virtuozzo.com>
>> >  |
>> >  |     compel: Do not loose sign of result in compat syscall
>> >
>> > It's due to compel interface which operates inside ia-32e mode
>> > where we have to keep sign of syscall up to a caller layer.
>> >
>> > Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
>> > ---
>> >  compel/arch/x86/src/lib/infect.c | 7 +++++++
>> >  1 file changed, 7 insertions(+)
>> >
>> > diff --git a/compel/arch/x86/src/lib/infect.c b/compel/arch/x86/src/lib/infect.c
>> > index ac5f8b0..e546ee3 100644
>> > --- a/compel/arch/x86/src/lib/infect.c
>> > +++ b/compel/arch/x86/src/lib/infect.c
>> > @@ -348,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;
>>
>> A nit:
>> TASK_SIZE_IA32?
>
> Not exactly. We could generate a mask from it but I think it's not that required,
> at least by now.

Wait, I kind of don't get it:
How map can be > 4 bytes if you get it from (user_regs_struct32::ax), which is
4 bytes (u32) for compat tasks?
We may insert BUG_ON(map & 0xffffffff00000000) or something.

-- 
             Dmitry


More information about the CRIU mailing list