Commit graph

10338 commits

Author SHA1 Message Date
Adrian Reber
ffac3d649d ci: add CentOS 8 based CI run
Our CentOS based CI run is based on CentOS 7. CentOS 8 exists already
for some time and CentOS 7 will probably go end of life at some point.

This adds a CentOS 8 based CI run to be prepared for the time CentOS 7
goes away.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
407404297e ci: switch centos7 to github actions
Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
369e17b293 travis: rename centos test to centos7
Because it is actually running on CentOS 7 and to easier distinguish it
from the new CentOS 8 test.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Radostin Stoyanov
68585dec91 criu-ns: Remove unreachable statement
Raising an exception breaks out of the normal
flow of control of a code block. When an exception
is not handled, the interpreter terminates execution
of the program, or returns to its interactive main loop.

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2020-11-08 01:55:25 -08:00
Mike Rapoport
953e87c7b4 ci: fix lazy-pages test selection
The special characters in the test selection regexp should no be esaped
for the regexp to work properly.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
8722bf012c ci: 'fix' lazy tests
Most (all?) lazy tests are not being executed if "$KERN_MAJ" -ge "4" and
"$KERN_MIN" -ge "18". Currently most CI systems are running on something
with 5.4.x which means $KERN_MAJ is greater than 4 but $KERN_MIN is less
than 18 and so we are not running any lazy tests.

This commit removes the complete lazy test kernel version detection as
kernels on the CI systems are new enough to always have all required
features.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
50878f4f7a CI: distribute CI jobs between CI systems
Move podman, openj9, x86_64 tests from Travis to GitHub Actions.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
0e47308d0f CI: rename 'travis' to 'ci'
CRIU is already using multiple CI systems and not just Travis. This
renames all Travis related things to 'ci' to show it is actually
independent of Travis.

Just a simple rename.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
2d290eeb0a namespaces: fix 'Declaring variable "path" without initializer'
criu/namespaces.c:529: var_decl: Declaring variable "path" without initializer.
criu/namespaces.c:602: uninit_use_in_call: Using uninitialized value "*path" as argument to "%s" when calling "print_on_level".

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
cec432500d coverity: img_raw_fd() returns a negative number
criu/pagemap.c:245: negative_return_fn: Function "img_raw_fd(pr->pi)" returns a negative number.
criu/pagemap.c:245: assign: Assigning: "fd" = "img_raw_fd(pr->pi)".
criu/pagemap.c:258: negative_returns: "fd" is passed to a parameter that cannot be negative.

criu/ipc_ns.c:762: negative_return_fn: Function "img_raw_fd(img)" returns a negative number.
criu/ipc_ns.c:762: assign: Assigning: "ifd" = "img_raw_fd(img)".
criu/ipc_ns.c:768: negative_returns: "ifd" is passed to a parameter that cannot be negative.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
84df563c5c sk-unix: ignore coverity chroot() warning
criu/sk-unix.c:1173: chroot_call: Calling chroot: "chroot(".")".
criu/sk-unix.c:1175: chroot: Calling function "close_safe" after chroot() but before calling chdir("/").

criu/sk-unix.c:1251: chroot_call: Calling chroot: "chroot(".")".
criu/sk-unix.c:1263: chroot: Calling function "print_on_level" after chroot() but before calling chdir("/").

Coverity also says:

175312, 175313 Insecure chroot

If a call to chroot is not followed by a call to chdir("/") the chroot jail confinement can be violated.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
ef4ec3261c cr-dump: get_service_fd() is passed to a parameter that cannot be negative
Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
d95c2683b9 util: fix double_close false positive
Coverity does not understand how close_fds() works.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
5527329ba2 dump: Potential leak of memory pointed to by 'si'
Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
fc20d280c3 coverity: fix parameter_hidden: declaration hides parameter
Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
73ed071e05 restore: Value stored to 'ret' is never read
Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
53501e5e83 cr-dump: Potential leak of memory pointed to by 'si'
Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
36f9700b13 vdso-compat: let coverity know that the function does not return
Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
62ab67ed5a coverity: ignore CHECKED_RETURN
Ignore coverity errors about CHECKED_RETURN.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
42e3e2e843 autofs: Potential leak of memory pointed to by 'token'
Using strsep() moves the pointer of the original string and this
introduces a copy of the malloc()ed memory to be able to free() it
later.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
84ffb965c2 sk-unix: do not overwrite function parameter
The function collect_one_unixsk() has a parameter 'i' and at the same
time has a variable, in a loop, with the name 'i'.

This is no real error or problem, because the function parameter 'i' is
never used in the whole function.

Just trying to reduce confusion and making a code checker happy.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
eb741528f1 Use 'is None' instead of '== None'
Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
407d3fe0fe bfd: remove unused line
Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
bbca79ab66 coredump: remove two unused variables
Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
6a9bff88b5 lib/py: remove unused variable
Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
e13a7ecd27 infect: initialize struct to avoid CLANG_WARNING
Using scan-build there is a warning about

 infect.c:231:17: warning: The left operand of '!=' is a garbage value
                 if (ss->state != 'Z') {

which is a false positive as every process will have a 'Status' field,
but initializing the structure makes the clang analyzer silent.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Adrian Reber
b80dd7e7c0 lock: disable clang_analyzer for the LOCK_BUG_ON() macro
The clang analyzer, scan-build, cannot correctly handle the
LOCK_BUG_ON() macro. At multiple places there is the following warning:

  Error: CLANG_WARNING:
    criu/pie/restorer.c:1221:4: warning: Dereference of null pointer

  include/common/lock.h:14:35: note: expanded from macro 'LOCK_BUG_ON'
               *(volatile unsigned long *)NULL = 0xdead0000 + __LINE__
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~

This just disable the clang analyzer for the LOCK_BUG_ON() macro.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
Michał Cłapiński
2ec05a0563 compel: don't mmap parasite as RWX
Some kernels have W^X mitigation, which means they won't execute memory
blocks if that memory block is also writable or ever was writable. This
patch enables CRIU to run on such kernels.

1. Align .data section to a page.
2. mmap a memory block for parasite as RX.
3. mprotect everything after .text as RW.

Signed-off-by: Michał Cłapiński <mclapinski@google.com>
2020-11-08 01:55:25 -08:00
Radostin Stoyanov
53dd29e93a cr-restore: Wait child & reap zombies if PID=1
When criu restore runs as PID=1 it has an additional responsibility to
reap zombie processes.

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-11-08 01:55:25 -08:00
Radostin Stoyanov
265569a40f criu-ns: Use PID 1 on restore
criu-ns performs double fork, which results in criu restore
using PID=2. Thus, if a user is trying to restore a process
with that PID, the restore will fail.

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2020-11-08 01:55:25 -08:00
Adrian Reber
e18017285b flog: Missing varargs init or cleanup (VARARGS)
CID 302713 (#1 of 1): Missing varargs init or cleanup (VARARGS)
 va_end was not called for argptr.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-11-08 01:55:25 -08:00
prakritigoyal19
532944695f Add flog to CRIU
Change made through this commit:
- Include copy of flog as a seperate tree.
- Modify the makefile to add and compile flog code.

Signed-off-by: prakritigoyal19 <prakritigoyal19@gmail.com>
2020-11-08 01:55:25 -08:00
Radostin Stoyanov
bfb051a51c criu-ns: Convert c_char_p strings to bytes object
class ctypes.c_char_p
    Represents the C char * datatype when it points to a zero-
    terminated string. For a general character pointer that may
    also point to binary data, POINTER(c_char) must be used.
    The constructor accepts an integer address, or a bytes object.

https://docs.python.org/3/library/ctypes.html#ctypes.c_char_p

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2020-11-08 01:55:25 -08:00
Radostin Stoyanov
3f71897290 criu-ns: Print usage info when no args provided
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2020-11-08 01:55:25 -08:00
Radostin Stoyanov
226efaac9b criu-ns: Convert to python3 style print() syntax
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2020-11-08 01:55:25 -08:00
Radostin Stoyanov
ca5c93d383 python: Replace xrange with range
In Py2 `range` returns a list and `xrange` creates a sequence object
that evaluates lazily. In Py3 `range` is equivalent to `xrange` in Py2.

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-11-08 01:55:25 -08:00
Pavel Emelyanov
1609a345a5 crns.py: New attempt to have --unshare option
So, here's the enhanced version of the first try.

Changes are:

1. The wrapper name is criu-ns instead of crns.py
2. The CLI is absolutely the same as for criu, since the script
   re-execl-s criu binary. E.g.
	   scripts/criu-ns dump -t 1234 ...
   just works
3. Caller doesn't need to care about substituting CLI options,
   instead, the scripts analyzes the command line and
   a) replaces -t|--tree argument with virtual pid __if__ the
      target task lives in another pidns
   b) keeps the current cwd (and root) __if__ switches to another
      mntns. A limitation applies here -- cwd path should be the
      same in target ns, no "smart path mapping" is performed. So
      this script is for now only useful for mntns clones (which
      is our main goal at the moment).

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Looks-good-to: Andrey Vagin <avagin@openvz.org>
2020-11-08 01:55:25 -08:00
Andrei Vagin
f68da4a86f criu: Version 3.15
This is yet another big release with many new features in it:

* Introduced criu-image-streamer
* Added MIPS support.
* Allow checkpointing out of existing PID namespace and
  restoring into existing PID namespace.
* Added additional file validation mechanisms
* Added support to checkpoint and restore BPF hash maps and array maps.
* Initial cgroup2 support

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-11-03 08:31:28 -08:00
Adrian Reber
5a655e890a travis: install gzip and redhat-rpm-config for Fedora Rawhide based tests
Signed-off-by: Adrian Reber <areber@redhat.com>
2020-10-20 00:18:24 -07:00
Mike Rapoport
1062cc4fed x86/asm: update test_bit() and test_and_set_bit()
Build on Fedora Core 33 produces the following warnings:

include/common/asm/bitops.h: Assembler messages:
include/common/asm/bitops.h:37: Warning: no instruction mnemonic suffix given and no register operands; using default for `bt'
include/common/asm/bitops.h: Assembler messages:
include/common/asm/bitops.h:63: Warning: no instruction mnemonic suffix given and no register operands; using default for `bts'

Update test_bit() and test_and_set_bit() implementation with recent
version from the Linux kernel to fix the warning.

Fixes #1217
Reported-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
2020-10-20 00:18:24 -07:00
Andrey Zhadchenko
c7726b7f35 zdtm: add alternative socket filter
A little rework of sock_filter test to be able to use it with different
filters

Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
2020-10-20 00:18:24 -07:00
Andrey Zhadchenko
5c4cc46fdc sockets: fix incorrect malloc size
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
2020-10-20 00:18:24 -07:00
Wojciech Marczenko
749eb33a92 compel: Calculate sh_addr if not provided by linker
GNU ld precalculates this information but lld does not. With this
change, handle-elf.c calculates those addresses on its own.

When calculating addresses sections with SHF_ALLOC bit are put one after
another, respecting their alignment requirements. This matches the way
how the blob is constructed by copying section contents.

Signed-off-by: Wojciech Marczenko <marczenko@google.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-10-20 00:18:24 -07:00
Adrian Reber
867dd27c96 util: Improper use of negative value (NEGATIVE_RETURNS)
CID 73358 (#1 of 1): Improper use of negative value (NEGATIVE_RETURNS)
 sk is passed to a parameter that cannot be negative.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-10-20 00:18:24 -07:00
Adrian Reber
16aea4a7c9 mount: Explicit null dereferenced (FORWARD_NULL)
CID 181217 (#1 of 1): Explicit null dereferenced (FORWARD_NULL)
 Passing null pointer mntns to mntns_get_root_fd, which dereferences it.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-10-20 00:18:24 -07:00
Adrian Reber
5f0674075e util: Improper use of negative value (NEGATIVE_RETURNS)
CID 192968 (#1 of 1): Improper use of negative value (NEGATIVE_RETURNS)
 dup(fd) is passed to a parameter that cannot be negative. [show details]

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-10-20 00:18:24 -07:00
Adrian Reber
ca7a832b5e page-xfer: Argument cannot be negative (NEGATIVE_RETURNS)
CID 73358 (#2 of 2): Argument cannot be negative (NEGATIVE_RETURNS)
 sk is passed to a parameter that cannot be negative.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-10-20 00:18:24 -07:00
Adrian Reber
f0e48be482 sk-netlink: Argument cannot be negative (NEGATIVE_RETURNS)
CID 73378 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
 sk is passed to a parameter that cannot be negative.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-10-20 00:18:24 -07:00
Adrian Reber
4e42278715 kerndat: Argument cannot be negative (NEGATIVE_RETURNS)
CID 92720 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
 pfd is passed to a parameter that cannot be negative.

CID 92747 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
 pfd is passed to a parameter that cannot be negative.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-10-20 00:18:24 -07:00
Adrian Reber
50dbcadf03 net: Argument cannot be negative (NEGATIVE_RETURNS)
CID 178391 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
 sk is passed to a parameter that cannot be negative.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-10-20 00:18:24 -07:00