2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 22:05:36 +00:00
Commit Graph

9923 Commits

Author SHA1 Message Date
Dmitry Safonov
e73df268af pie/build: Add CFLAGS_PIE to CFLAGS
There is a little difference between ccflags-y and CFLAGS, except the
local/global visibility: nmk adds $(CFLAGS) to nmk-asflags and assembles
using them, but without ccflags-y.

The other possible way would be adding asflags-y with CFLAGS_PIE, but
I'm not convinced - let's update CFLAGS for the time being.

Signed-off-by: Dmitry Safonov <dima@arista.com>
2019-09-07 15:59:52 +03:00
Dmitry Safonov
a96f0f1877 util-vdso: Check chain for STN_UNDEF
Rather than chain[chain] != STN_UNDEF.
Seems like, on !ARM32 vdso there are more symbols and less chance to hit
this "feature".

Fixes parsing of __vdso_clock_gettime symbol on v5.1 arm kernel.

Signed-off-by: Dmitry Safonov <dima@arista.com>
2019-09-07 15:59:52 +03:00
Dmitry Safonov
ee6412fa20 x86/vdso: Don't insert trampolines in vsyscall
The patch "util-vdso: Check chain for STN_UNDEF" fixed an issue about
not discovering present symbols on vdso. While it's a good and a proper
fix, as the result __kernel_vsyscall started being patched.
Which in result broke zdtm trampoline test on ia32.

So, let's omit patching vsyscall while #512 issue is not fixed.
We might actually refrain patching it for long time as it doesn't access
vvar, so there is little sense in doing patching.

Signed-off-by: Dmitry Safonov <dima@arista.com>
2019-09-07 15:59:52 +03:00
Dmitry Safonov
b2efa720ce rt-vdso: Be verbose if !blobs_matches()
(00.251007) pie: 4: vdso: Runtime vdso mismatches dumpee, generate proxy

And I want to know why :)

Signed-off-by: Dmitry Safonov <dima@arista.com>
2019-09-07 15:59:52 +03:00
Dmitry Safonov
670648c931 arm/pie: Provide __clear_cache()
After patching code - we need to flush CPU cache, it's done with
__builtin___clear_cache(). As we don't link to libgcc, provide a helper
that wraps ARM-specific syscall.

Fixes:
  LINK     criu/pie/restorer.built-in.o
ld: ./criu/arch/arm/vdso-pie.o: in function `insert_trampoline':
/root/criu/criu/arch/arm/vdso-pie.c:32: undefined reference to `__clear_cache'

Signed-off-by: Dmitry Safonov <dima@arista.com>
2019-09-07 15:59:52 +03:00
Dmitry Safonov
934a050788 arm: Provide aeabi helpers in ARM format
We're building PIEs in arm format rather than in thumb.
Copy helpers from libgcc, provide a proper define and
link them into blobs.

Also substitute tabs by spaces, how it should have been
in pie/Makefile - tabs are for recipes.

Fixes:
  LINK     criu/pie/parasite.built-in.o
criu/pie/pie.lib.a(util-vdso.o): In function `elf_hash':
/criu/criu/pie/util-vdso.c:61: undefined reference to `__aeabi_uidivmod'
/criu/scripts/nmk/scripts/build.mk:209: recipe for target 'criu/pie/parasite.built-in.o' failed

Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>
2019-09-07 15:59:52 +03:00
Dmitry Safonov
a856c48e77 arm: Build {pie-, }util-vdso with CONFIG_VDSO_32
Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>
2019-09-07 15:59:52 +03:00
Dmitry Safonov
d6ce398eb4 vdso/arm32: Add vdso trampoline support
Signed-off-by: Dmitry Safonov <dima@arista.com>
2019-09-07 15:59:52 +03:00
Dmitry Safonov
d2b4eddf52 parasite-vdso: Add ugly casts for arm32
criu/pie/parasite-vdso.c: In function 'remap_rt_vdso':
criu/pie/parasite-vdso.c:144:17: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
  if (sys_munmap((void *)vma_vdso->start, vma_entry_len(vma_vdso))) {
                 ^
criu/pie/parasite-vdso.c:154:17: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
  if (sys_munmap((void *)vma_vvar->start, vma_entry_len(vma_vvar))) {
                 ^
cc1: all warnings being treated as errors

Signed-off-by: Dmitry Safonov <dima@arista.com>
2019-09-07 15:59:52 +03:00
Dmitry Safonov
8824579c8a vdso/arm: Add vdso symbols from kernel
Signed-off-by: Dmitry Safonov <dima@arista.com>
2019-09-07 15:59:52 +03:00
Dmitry Safonov
37d3781576 cr-check: Add check for mremap() of special mappings
During restore any VMA that's a subject to ASLR should be moved at the
same address as was on a checkpoint. Previously, ports to non-x86
architectures had problems with VDSO mremap(). On those platforms kernel
needs "landing" for return to userspace in some cases.
Usually, vdso provides this landing and finishes restoring of registers.
That's `int80_landing_pad` on ia32. On arm64/arm32 it's sigtrap for
SA_RESTORER - to proceed after signal processing.

That's why kernel needs to track the position of landing.
On modern kernels for platform we support it's already done - however,
for older kernels some patches needs to be backported for C/R.

Provide the checks for mremap() of special VMAs: that CRIU has suitable
kernel to work on and if we'll have some new platforms - that kernel
tracks the position of landing.

Signed-off-by: Dmitry Safonov <dima@arista.com>
2019-09-07 15:59:52 +03:00
Radostin Stoyanov
cd58de7a2b pb2dict: Resolve Python 2/3 compatibility issues
In Python 3, bytes has only a decode() method, and string has only
an encode() method. [1]

The modules quopri and base64 from the Python Standard Library perform
quoted-printable transport encoding and decoding with both Python 2 [2]
and Python 3 [3].

[1] https://docs.python.org/3/howto/pyporting.html#text-versus-binary-data
[2] https://docs.python.org/2/library/quopri.html
[3] https://docs.python.org/3/library/quopri.html

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-09-07 15:59:52 +03:00
Radostin Stoyanov
831ae18dac pb2dict: Fix is_string() check for Python 2
In the __main__ module, __builtins__ is the built-in module builtins.
In any other module, __builtins__ is an alias for the dictionary of
the builtins module itself. [1]

Thus, hasattr(__builtins__, "basestring") would only work in __main__
module. Since pb2dict is part of pycriu and is intended to be called
by modules other than __main__, we can assume that __builtins__ would
always be a dictionary (not a module).

In Python 2, basestring is a superclass for str and unicode. [2]
However, the assignment statement creates a variable basestring in the
local scope of the function is_string() which, in Python 2, causes a
failure with UnboundLocalError. In order to mitigate this issue the
local variable name has been changed to string_types.

Fixes #708

[1] https://docs.python.org/2/reference/executionmodel.html#builtins-and-restricted-execution
[2] https://docs.python.org/2/library/functions.html#basestring

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-09-07 15:59:52 +03:00
Pavel Emelianov
33bc00a158 zdtm: Check stats file presence before reading
In some cases the stats-dump file can be missing, so do not
crash the whole zdtm.py in this case.

https://ci.openvz.org/job/CRIU/job/criu-live-migration/job/criu-dev/2362/console

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2019-09-07 15:59:52 +03:00
Radostin Stoyanov
c399235244 aarch64: Remove stack pointer from clobber list
Since gcc version 9.1 was added the restriction that the clobber list
of an inline assembly should not contain the stack pointer register.

https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=9d1cdb749a1

In commit 901f5d4 have been fixed most of the build failures related to
this gcc restriction. In this patch is resolved a build error that
occurs only on aarch64.

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-09-07 15:59:52 +03:00
Andrei Vagin
31c3f3bc1b test/s390: add a new patch to xtables libraries
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-09-07 15:59:52 +03:00
Andrei Vagin
7338a0e74c util: use F_DUPFD when we don't want to overwrite an existing descriptor
Right now we use fcntl(F_GETFD) to check whether a target descriptor
is used and then we call dup2(). Actually, we can do this for one system
call.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-09-07 15:59:52 +03:00
Pavel Emelianov
77d88920fb stats: Make dstats shmem
Dumping shmem segments causing stats "pages written" counter to mismatch
the real pages* sizes. This is due to ipcns' dumping happens in another
process and the relevant shmem dumping counters remain in its address space.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-09-07 15:59:52 +03:00
Pavel Emelianov
b336fa2e32 zdtm: Check pages stats after dump
After dump command -- verify that the amount of bytes counted in
stats-dump matches the real sizes of pages-*.img files.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-09-07 15:59:52 +03:00
Pavel Emelianov
72ce634f43 shmem: Save pages stats too
Shmem pages are written in the same set of images as regular
pages are, but stats for those are not collected. Fix this, but
keep the counts separate to have more info.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-09-07 15:59:51 +03:00
Pavel Emelianov
5156f2dc0d mem: Update stats for overflow page pipes
Since commit b5dff62e we skipped updating dump stats for pages
that overflowed the page-pipe and thus got flushed in "chunk"
mode.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-09-07 15:59:51 +03:00
Radostin Stoyanov
bf62dbbe08 make: Use asciidoctor by default
The final release of asciidoc was on Sep 29, 2017 and the development
is continued under asciidoctor.

With commit 0493724 (Documentation: Allow to use asciidoctor for
formatting man pages) was added support for this tool by introducing
USE_ASCIIDOCTOR.

However, using asciidoctor by default might be a better option. With
this change CRIU will use asciidoctor if installed. Otherwise, it will
fallback to asciidoc.

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-09-07 15:59:51 +03:00
Radostin Stoyanov
8accfe6cc9 python: Drop six dependency
From the python-six module is used only six.string_types in the
is_string() function. An alternative solution is to use
basestring with additional if statement for Python 3 compatibility.

This change avoids the dependency on the six module.

However, this module is required by junit_xml and it is not listed
as a dependency in the CentOS 7 package python2-junit_xml.

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-09-07 15:59:51 +03:00
Adrian Reber
da652c8b37 sk-unix: fix coverity NULL_RETURNS
criu-3.12/criu/sk-unix.c:1225: dereference: Dereferencing "ns", which is
known to be "NULL".

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:51 +03:00
Adrian Reber
7765a6c3fc image: fix coverity RESOURCE_LEAK
criu-3.12/criu/image.c:103: leaked_storage: Variable "img" going out of
scope leaks the storage it points to.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:51 +03:00
Adrian Reber
5a29e253f6 util: fix coverity FORWARD_NULL
criu-3.12/criu/util.c:505: var_deref_model: Passing null pointer "dir"
to "dirfd", which dereferences it. (The dereference is assumed on the
basis of the 'nonnull' parameter attribute.)

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:51 +03:00
Adrian Reber
88d8979b5d sk-unix: fix coverity RESOURCE_LEAK
criu-3.12/criu/sk-unix.c:1893: leaked_handle: Handle variable "sk" going
out of scope leaks the handle.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:51 +03:00
Adrian Reber
2f74e55a18 sk-unix: fix clang 'value is never read'
criu-3.12/criu/sk-unix.c:1545:5: warning: Value stored to 'ret' is never
read

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:51 +03:00
Adrian Reber
9406f1be4e sk-queue: fix clang 'potential memory leak'
criu-3.12/criu/sk-queue.c:272:6: warning: Potential leak of memory
pointed to by 'pe.scm'

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:51 +03:00
Adrian Reber
6f44f78310 sk-inet: fix clang 'potential memory leak'
criu-3.12/criu/sk-inet.c:581:2: warning: Potential leak of memory
pointed to by 'ie.ifname'

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:51 +03:00
Adrian Reber
b87b02729a sk-inet: fix coverity RESOURCE_LEAK
criu-3.12/criu/sk-inet.c:822: leaked_handle: Handle variable "sk" going
out of scope leaks the handle.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:51 +03:00
Adrian Reber
0df6ddba69 proc_parse: fix coverity RESOURCE_LEAK
criu-3.12/criu/proc_parse.c:2280: leaked_storage: Variable "dir" going
out of scope leaks the storage it points to.

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-09-07 15:59:51 +03:00
Adrian Reber
5b358ebdc3 pie/restorer: fix clang 'value is never read'
criu-3.12/criu/pie/restorer.c:1514:2: warning: Value stored to 'ret' is
never read

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:51 +03:00
Adrian Reber
bf2d03b785 page-xfer: fix clang 'value is never read'
criu-3.12/criu/page-xfer.c:988:3: warning: Value stored to 'ret' is
never read

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:51 +03:00
Adrian Reber
82d6ef6d8a pagemap: fix coverity FORWARD_NULL
criu-3.12/criu/pagemap.c:694: var_deref_model: Passing "pr" to
"free_pagemaps", which dereferences null "pr->pmes"

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:51 +03:00
Adrian Reber
08a283d29e pagemap: fix clang 'free released memory'
criu-3.12/criu/pagemap.c:460:2: warning: Attempt to free released memory

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:51 +03:00
Adrian Reber
75edc02f66 mem: fix coverity RESOURCE_LEAK
criu-3.12/criu/mem.c:597:3: warning: Value stored to 'ret' is never read

criu-3.12/criu/mem.c:632: leaked_storage: Variable "img" going out of
scope leaks the storage it points to.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:51 +03:00
Adrian Reber
beecbf0968 lsm: fix clang 'Use of memory after it is freed'
criu-3.12/criu/lsm.c:257:3: warning: Use of memory after it is freed

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:51 +03:00
Adrian Reber
fe1c72a098 lib/c: fix coverity DEADCODE
criu-3.12/lib/c/criu.c:869: dead_error_line: Execution cannot reach this
statement: "free(ptr);".

criu-3.12/lib/c/criu.c:906: dead_error_line: Execution cannot reach this
statement: "free(ptr);".

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:50 +03:00
Adrian Reber
27dd87e99a libcriu: fix coverity RESOURCE_LEAK
criu-3.12/lib/c/criu.c:255: leaked_storage: Variable "rpc" going out of
scope leaks the storage it points to.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:50 +03:00
Adrian Reber
688f02a139 log: fix coverity OVERRUN
This fixes a coverity buffer overflow warning:

criu-3.12/criu/log.c:344: overrun-local: Overrunning array of 1024 bytes
at byte offset 1031 by dereferencing pointer "early_log_buffer +
early_log_buf_off + log_size". [Note: The source code implementation of
the function has been overridden by a builtin model.]

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:50 +03:00
Adrian Reber
288a4a953a image: fix clang 'dereference of a null pointer'
criu-3.12/criu/include/image.h:129:9: warning: Dereference of null
pointer

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:50 +03:00
Adrian Reber
920c4a6afc files-reg: fix coverity NULL_RETURNS
criu-3.12/criu/files-reg.c:1574: dereference: Dereferencing "rmi", which
is known to be "NULL".

criu-3.12/criu/files-reg.c:1582: dereference: Dereferencing "tmi", which
is known to be "NULL".

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:50 +03:00
Adrian Reber
57d4a78aa3 files: fix coverity RESOURCE_LEAK
criu-3.12/criu/files.c:1250: leaked_storage: Variable "dir" going out of
scope leaks the storage it points to.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:50 +03:00
Adrian Reber
7d152adf65 cr-service: fix clang 'dereference of a null pointer'
criu-3.12/criu/cr-service.c:933:7: warning: Access to field 'keep_open'
results in a dereference of a null pointer (loaded from variable 'msg')

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:50 +03:00
Adrian Reber
defbd43351 cr-service: fix coverity STRING_OVERFLOW
criu-3.12/criu/cr-service.c:1305: fixed_size_dest: You might overrun the
108-character fixed-size string "server_addr.sun_path" by copying
"opts.addr" without checking the length.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:50 +03:00
Adrian Reber
c189a9bbf2 compel: fix clang 'value stored is never read'
criu-3.12/compel/src/lib/infect.c:276:3: warning: Value stored to 'ret'
is never read

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:50 +03:00
Adrian Reber
8502bc2010 cgroup: fix clang 'free released memory'
criu-3.12/criu/cgroup.c:927:2: warning: Attempt to free released memory

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:50 +03:00
Adrian Reber
ac495fbd3f autofs: fix coverity RESOURCE_LEAK
criu-3.12/criu/autofs.c:114: leaked_storage: Variable "path" going out
of scope leaks the storage it points to.

criu-3.12/criu/autofs.c:254: leaked_storage: Variable "opts" going out
of scope leaks the storage it points to.

criu-3.12/criu/autofs.c:719: leaked_storage: Variable "path" going out
of scope leaks the storage it points to.

criu-3.12/criu/autofs.c:980: leaked_storage: Variable "img" going out of
scope leaks the storage it points to.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-09-07 15:59:50 +03:00
Zhang Ning
11b3825ca3 x86/crtools: do not error when YMM is missing
for Intel Apollo Lake SOC, its cpuinfo and fpu features:
cpu: x86_family 6 x86_vendor_id GenuineIntel x86_model_id Intel(R) Celeron(R) CPU J3455 @ 1.50GHz
cpu: fpu: xfeatures_mask 0x11 xsave_size 1088 xsave_size_max 1088 xsaves_size 704
cpu: fpu: x87 floating point registers     xstate_offsets      0 / 0      xstate_sizes    160 / 160

this CPU doesn't have AVX registers, YMM feature.

when CRIU runs on this CPU, it will report dump error:
Dumping GP/FPU registers for 4888
Error (criu/arch/x86/crtools.c:362): x86: Corruption in XFEATURE_YMM area (expected 64 but 0 obtained)
Error (criu/cr-dump.c:1278): Can't infect (pid: 4888) with parasite

that's because x86/crtools.c will still valid YMM xsave frame, thus fail to dump.

bypass unsupported feature, to make CRIU runs this kinds of CPUs.

Cc: Chen Hu <hu1.chen@intel.com>
Signed-off-by: Zhang Ning <ning.a.zhang@intel.com>
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2019-09-07 15:59:50 +03:00