• Filipe Brandenburger's avatar
    cr-check: Inspect errno on syscall failures · e7ba9095
    Filipe Brandenburger authored
    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 8ceab588 ("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.
    
    Also make the comparisons for the return value explicit checks for a
    negative value (expected -1) instead of just failing on a non-zero value
    with the implicit comparison.
    
    Add %m to report what errno was set to on failed syscalls, to make it
    easier to troubleshoot a check failure.
    
    Tested that now `criu check --ms` stopped reporting the misleading:
      prctl: One needs CAP_SYS_RESOURCE capability to perform testing.
    Instead, now it reports:
      Error (cr-check.c:165): System call kcmp is not supported: No such process
      Warn  (cr-check.c:195): Skipping unssuported PR_SET_MM_MAP: Invalid argument
      prctl: PR_SET_MM is not supported: Invalid argument
    And those messages include the error message that explains why the
    syscall failed.
    Reported-by: 's avatarSaied Kazemi <saied@google.com>
    Fixes: 8ceab588 ("crtools: no more linked with builtin syscall")
    Cc: Laurent Dufour <ldufour@linux.vnet.ibm.com>
    Signed-off-by: 's avatarFilipe Brandenburger <filbranden@google.com>
    Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
    e7ba9095
Name
Last commit
Last update
..
arch Loading commit data...
include Loading commit data...
pie Loading commit data...
Makefile Loading commit data...
Makefile.config Loading commit data...
Makefile.crtools Loading commit data...
Makefile.version Loading commit data...
action-scripts.c Loading commit data...
aio.c Loading commit data...
bfd.c Loading commit data...
bitmap.c Loading commit data...
cgroup.c Loading commit data...
cr-check.c Loading commit data...
cr-dedup.c Loading commit data...
cr-dump.c Loading commit data...
cr-errno.c Loading commit data...
cr-exec.c Loading commit data...
cr-restore.c Loading commit data...
cr-service.c Loading commit data...
crtools.c Loading commit data...
eventfd.c Loading commit data...
eventpoll.c Loading commit data...
fault-injection.c Loading commit data...
fifo.c Loading commit data...
file-ids.c Loading commit data...
file-lock.c Loading commit data...
files-ext.c Loading commit data...
files-reg.c Loading commit data...
files.c Loading commit data...
fsnotify.c Loading commit data...
image-desc.c Loading commit data...
image.c Loading commit data...
ipc_ns.c Loading commit data...
irmap.c Loading commit data...
kcmp-ids.c Loading commit data...
kerndat.c Loading commit data...
libnetlink.c Loading commit data...
log.c Loading commit data...
lsm.c Loading commit data...
mem.c Loading commit data...
mount.c Loading commit data...
namespaces.c Loading commit data...
net.c Loading commit data...
netfilter.c Loading commit data...
page-pipe.c Loading commit data...
page-read.c Loading commit data...
page-xfer.c Loading commit data...
pagemap-cache.c Loading commit data...
parasite-syscall.c Loading commit data...
pie-util-fd.c Loading commit data...
pie-util-vdso.c Loading commit data...
pie-util.c Loading commit data...
pipes.c Loading commit data...
plugin.c Loading commit data...
proc_parse.c Loading commit data...
protobuf-desc.c Loading commit data...
protobuf.c Loading commit data...
pstree.c Loading commit data...
ptrace.c Loading commit data...
rbtree.c Loading commit data...
rst-malloc.c Loading commit data...
seccomp.c Loading commit data...
seize.c Loading commit data...
shmem.c Loading commit data...
sigframe.c Loading commit data...
signalfd.c Loading commit data...
sk-inet.c Loading commit data...
sk-netlink.c Loading commit data...
sk-packet.c Loading commit data...
sk-queue.c Loading commit data...
sk-tcp.c Loading commit data...
sk-unix.c Loading commit data...
sockets.c Loading commit data...
stats.c Loading commit data...
string.c Loading commit data...
sysctl.c Loading commit data...
sysfs_parse.c Loading commit data...
timerfd.c Loading commit data...
tty.c Loading commit data...
tun.c Loading commit data...
util.c Loading commit data...
uts_ns.c Loading commit data...
vdso.c Loading commit data...