Re: [PATCH v3 1/2] x86_64,signal: Fix SS handling for signals delivered to 64-bit programs

From: Andy Lutomirski
Date: Wed Mar 18 2015 - 14:06:30 EST


On Wed, Mar 18, 2015 at 10:48 AM, Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> On 03/18, Andrey Wagin wrote:
>>
>> This commit breaks CRIU. I don't have any details yet. I'm going to
>> investigate this issue and provide more details tomorrow.
>>
>> [root@avagin-fc19-cr criu]# setsid sleep 1000 &
>> [1] 1225
>> [root@avagin-fc19-cr criu]# ps -C sleep
>> PID TTY TIME CMD
>> 1226 ? 00:00:00 sleep
>> [root@avagin-fc19-cr criu]# ./criu dump -t 1226 -D dump --shell-job
>> [root@avagin-fc19-cr criu]# ./criu restore -D dump --shell-job
>> Error (parasite-syscall.c:923): Task is in unexpected state: b7f (SIGSEGV)
>
> This is funny. Because currenty I am looking into criu sources for quite
> different reason (and I HATE this reason ;)
>
> Shot in a dark afer a quick grep: restore_gpregs() should initialize ->ss?
>
> perhaps something like below... obviously uncompiled/untested.
>
> And my grep can't find the definition of UserX86RegsEntry in crtools...
> Perhaps the change below needs CPREG1(ss, anothername).
>
> Seriously, where is UserX86RegsEntry?
>
> Oleg.
>
>
> --- a/arch/x86/crtools.c
> +++ b/arch/x86/crtools.c
> @@ -475,6 +475,7 @@ int restore_gpregs(struct rt_sigframe *f, UserX86RegsEntry *r)
> CPREG2(rip, ip);
> CPREG2(eflags, flags);
> CPREG1(cs);
> + CPREG1(ss);
> CPREG1(gs);
> CPREG1(fs);

Huh? Is CRIU actually trying to build an entire sigcontext from
scratch here? I don't see how this can reliably work across kernel
versions or CPU versions.

Also, what's up with CPREG1(gs) and CPREG1(fs)? I assume that's
redundant, because that hasn't worked for many years, but CRIU works,
so there must be correct code somewhere to restore those regs.

--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/