[CRIU] [PATCH] cr-check: Inspect errno on syscall failures

Laurent Dufour ldufour at linux.vnet.ibm.com
Tue Mar 15 02:44:30 PDT 2016


On 14/03/2016 18:47, Filipe Brandenburger wrote:
> Hi Pavel, Laurent,

Hi Filipe, and thanks a lot for the fix you did.

> On Mon, Mar 14, 2016 at 10:43 AM, Filipe Brandenburger
> <filbranden at google.com> wrote:
>> After replacing sys_kcmp with syscall() and sys_prctl with prctl(), the
>> API is changed to return -1 and set errno on failure (instead of
>> returning the negative value of the error code directly on return.)
>>
>> Commit 8ceab588a5ce91 ("crtools: no more linked with builtin syscall")
>> replaced calls to sys_kcmp and sys_prctl, but did not update the checks
>> for ret to check for -1 and errno, so update them here.
> 
> I hope this patch catches all the problems with ret = -EXXX vs.
> setting errno, I looked at commit 8ceab588a5ce91 and also some places
> where errno is being set (errno = -ret or errno = -fd) and I think
> they're all covered now.
> 
> There is still:
> - criu/pie/util.c which uses #define __sys(foo) foo but still assumes
> a sys_foo interface

These ones sounds good to me.

> - criu/include/lock.h which defines sys_futex to return -EXXX when
> errno is set (maybe the opposite approach of leaving errno set would
> be better since it works with pr_perror and %m?)

That may be a good idea, but we have to take care because this file is
used both by CRIU's user space process and by the parasite code. In the
later case, the C library is not there and sys_futex is implemented per
architecture and it returns the errno in the returned value.

Unfortunately, we don't have an errno variable in the parasite code (it
is defined in the C library and it is a per thread variable), so we must
rely on the most basic here and let the error value be returned as the
syscall returned code (otherwise, we don't know where to put the error
code).

Cheers,
Laurent



More information about the CRIU mailing list