Commit graph

10433 commits

Author SHA1 Message Date
Dmitry Safonov
e07e5eee3c compel: Provide compel_set_task_ext_regs()
Arch-dependend way to restore extended registers set.
Use it straight-away to restore per-thread registers.

Signed-off-by: Dmitry Safonov <dima@arista.com>
2021-03-09 00:50:22 -08:00
Dmitry Safonov
e9b1e0b74c compel: Store extended registers set in the thread context
Extended registers set for task is restored with rt_sigreturn() through
prepared sigframe. For threads it's currently lost.
Preserve it inside thread context to restore on thread curing.

Signed-off-by: Dmitry Safonov <dima@arista.com>
2021-03-09 00:50:22 -08:00
Dmitry Safonov
8394062e46 zdtm/fpu03: Add a test to check fpu C/R in a thread
CRIU dumps main thread and sub-threads differently, so there needed
a test to check if fpu is preserved across C/R in sub-threads.

Signed-off-by: Dmitry Safonov <dima@arista.com>
2021-03-09 00:50:22 -08:00
Dmitry Safonov
6e1cd5b6a7 zdtm/fpu00: Simplify ifdeffery
..to introduce a new one! ;-D

Signed-off-by: Dmitry Safonov <dima@arista.com>
2021-03-09 00:50:22 -08:00
Dmitry Safonov
2fdc09499d x86/compel/fault-inject: Add a fault-injection for corrupting extended regset
With pseudo-random garbage, the seed is printed with pr_err().
get_task_regs() is called during seizing the task and also for each
thread.
At this moment only for x86.

Signed-off-by: Dmitry Safonov <dima@arista.com>
2021-03-09 00:50:22 -08:00
Pavel Tikhomirov
e4e58a8f38 namespaces: properly handle errors of snprintf
If snprintf was truncated we should probably know about it instead of
continuing to increase off, as snprintf returns number of characters
which would have been written and not the number which was actually
written.

Normally we check snprintf only for overflow not for error, some modern
compilers print warnings if truncation was not checked.

Probably it was the case why we implemented [1], the truncation happened
and on the next iteration of for loop we've hit negative size for
snprintf and got -1.

Fixes: 90f043dea ("namespaces: handle errors of snprintf") [1]
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2021-03-02 08:09:44 -07:00
Dmitry Safonov
84be3047ad x86: Use PTRACE_GET_THREAD_AREA instead of sys_get_thread_area()
To minimize things done in parasite, PTRACE_GET_THREAD_AREA can be
used to get remote tls. That also removes an additional compat stack
(de)allocation in the parasite (also asm-coded syscall).

In order to use PTRACE_GET_THREAD_AREA, the dumpee should be stopped.
So, let's move this from criu to compel to non-seized state and put tls
into thread info on x86.

Signed-off-by: Dmitry Safonov <dima@arista.com>
2021-03-02 08:08:44 -07:00
Dmitry Safonov
f8cf0715e2 ci/compat: Check if tests are 32-bit ELFs
To be sure that we don't lose COMPAT_TEST=y on the way to make.

Signed-off-by: Dmitry Safonov <dima@arista.com>
2021-03-02 08:07:06 -07:00
Andrei Vagin
e0d4aef351 github/stale: separate labels with commas without following spaces
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2021-03-02 08:05:19 -07:00
Adrian Reber
168668ec75 ci: fix Fedora rawhide CI failures
It seems the Fedora rawhide /tmp is no longer 1777 but 755.

Change it back to 1777 to make our CI runs successful again.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-03-01 10:42:31 -07:00
Pavel Tikhomirov
ab395e423c plugin: check for plugin path truncation
New compilators print warnings if snprintf return value is not checked
for truncation. Let's make them happy.

Fixes: #1372
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2021-03-01 00:30:13 -07:00
Andrei Vagin
3397ac0a7c sk-unix: check whether a socket name is NULL before printing it
criu/include/log.h:72:2: error: '%s' directive argument is null [-Werror=format-overflow=]
   72 |  print_on_level(LOG_DEBUG,     \
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   73 |          LOG_PREFIX fmt, ##__VA_ARGS__)
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/sk-unix.c:133:2: note: in expansion of macro 'pr_debug'
  133 |  pr_debug("\t%s: ino %u peer_ino %u family %4d type %4d state %2d name %s\n",
      |  ^~~~~~~~
  CC       criu/stats.o

Fixes: #1373
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2021-02-24 08:14:04 -07:00
Andrei Vagin
950a88c741 bug: add __builtin_unreachable in BUG_ON_HANDLER
This will surpress false gcc warnings like this:
criu/stats.c:85:10: error: array subscript 4 is above array bounds
of 'struct timing[2]' [-Werror=array-bounds]
   85 |   return &rstats->timings[t];
      |          ^~~~~~~~~~~~~~~~~~~
criu/stats.c:25:16: note: while referencing 'timings'
   25 |  struct timing timings[RESTORE_TIME_NS_STATS];
      |                ^~~~~~~
cc1: all warnings being treated as errors

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2021-02-24 08:14:04 -07:00
Adrian Reber
42171caba4 test: fix test compilation on rawhide
The latest glibc has redefined SIGSTKSZ as 'sysconf (_SC_SIGSTKSZ)' and
this breaks a static char[] definition.

Hardcoding TESTSIGSTKSZ to 16384 in the test. This fixes:

 sigaltstack.c:17:13: error: variably modified 'stack_thread' at file scope
   17 | static char stack_thread[SIGSTKSZ + TEST_MSG_BUFFER_SIZE] __stack_aligned__;
      |             ^~~~~~~~~~~~
sigaltstack.c:18:13: error: variably modified 'stack_main' at file scope
   18 | static char stack_main[SIGSTKSZ + TEST_MSG_BUFFER_SIZE] __stack_aligned__;
      |             ^~~~~~~~~~

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-02-24 08:13:15 -07:00
Radostin Stoyanov
6110236b6d zdtm: Add javaTests output to .gitignore
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2021-02-18 23:14:20 -07:00
Radostin Stoyanov
7a8f426f15 test: Reduce verbosity of mvn output
The -q option will only show errors

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2021-02-18 23:14:20 -07:00
Radostin Stoyanov
89aa87484e javaTests: Add --file-locks option
Resolves #1370

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2021-02-18 23:14:20 -07:00
Radostin Stoyanov
2692215a5f file-lock: Add space in error message
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2021-02-18 23:14:20 -07:00
Adrian Reber
a277c84936 ci: use runc instead of crun for podman tests
The latest podman pulls in crun instead of runc. Unfortunately crun is
not built against libcriu and does not support checkpoint/restore.

Switch back to runc.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-02-18 21:04:01 -08:00
Nicolas Viennot
42c211285c seccomp: initialize seccomp_mode in all cases
In parse_pid_status(), it is assumed that the seccomp field can be
missing from /proc/pid/status. When the field is missing, it is not
properly initialized, leading to bad behavior.

We initialize seccomp_mode to SECCOMP_MODE_DISABLED by default,
similarly to what is done in compel/src/lib/infect.c:parse_pid_status.

Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
2021-02-09 23:22:06 -08:00
Andrey Zhadchenko
1b5dbe5678 zdtm: add second fifo_upon_unix test
This differs from the previous one by
1. using relative path instead of absolute
2. chdir() after setup

Reviewed-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
2021-02-09 09:15:58 -08:00
Andrey Zhadchenko
903b903d22 zdtm: add fifo upon unix socket test case
Create unix socket and unlink it. Make fifo in this place.

Reviewed-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
2021-02-09 09:15:58 -08:00
Andrey Zhadchenko
82f2033080 sk-unix: rework unix_resolve_name
Use SIOCUNIXFILE ioctl approach to get socket fd opened with O_PATH. Utilise it
for detecting deletion and resolving relative name. Preserve old method as
fallback if this new IOCTL fails.

Also remove overmount_sock crfail in zdtm. With the unix_resolve_name
reworked to use SIOCUNIXFILE criu can now pass this test.

Reviewed-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
2021-02-09 09:15:58 -08:00
Andrey Zhadchenko
a4c000e305 sk-unix: make criu respect existing files while restoring ghost unix socket fd
If there are any file in place of ghost unix socket, criu will delete it at
restore while trying to recreate ghost one.

Reviewed-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
2021-02-09 09:15:58 -08:00
Andrey Zhadchenko
8d92d46948 files-reg: rework strip_deleted
Moved strip_deleted to util and reworked it so other parts of criu can use
it without the need of files-reg.h

Reviewed-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
2021-02-09 09:15:58 -08:00
Andrey Zhadchenko
9546f39192 files: Don't forget on stripping deleted postfix on linked files
Otherwise we gonna accumulated "(deleted)" postfix generated by
kernel on every c/r iteration eventually overflowing PATH_MAX
which will make container undumpable.

Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
2021-02-09 09:15:58 -08:00
Adrian Reber
042560a2fd ci: move coverage run to github
This also connects the coverage run to codecov.io.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-02-06 14:56:12 -08:00
Andrei Vagin
3fb8cd3a4d test/zdtm: check that locks are not dumped if --file-locks isn't set
If criu finds a file lock and the --file-locks option isn't set, it
stops dumping processes, resumes them and exits with an error.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2021-02-06 14:44:39 -08:00
Andrei Vagin
7a64074c0b dump: dump has to fail if there is locks and --file-locks isn't set
If criu finds a file lock and the --file-locks option isn't set, it
stops dumping processes, resumes them and exits with an error.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2021-02-06 14:44:39 -08:00
Adrian Reber
81c3c9748a ci: move compat tests to Github Actions
Signed-off-by: Adrian Reber <areber@redhat.com>
2021-02-05 09:28:27 -08:00
Adrian Reber
4c3f3245e0 README.md: remove unused badges; add a few new badges
Signed-off-by: Adrian Reber <areber@redhat.com>
2021-02-05 09:23:45 -08:00
Adrian Reber
10cb8521da README.md: remove trailing whitespaces
Signed-off-by: Adrian Reber <areber@redhat.com>
2021-02-05 09:23:45 -08:00
Adrian Reber
5792612d31 ci: move asan and image streamer test to github
Signed-off-by: Adrian Reber <areber@redhat.com>
2021-02-05 09:22:52 -08:00
anatasluo
2cb1156e6a vdso: fix segmentation fault caused by char pointer array
When I compile criu with "make DEBUG=1" and run it to restore my
program, it produces a segmentation fault.

In aarch64, with compile flag "-O0", when criu executes the code in pie,
it is unable to visit the content of ARCH_VDSO_SYMBOLS. So I put these
variables into the stack.

Signed-off-by: anatasluo <luolongjuna@gmail.com>
2021-01-31 19:15:18 -08:00
Adrian Reber
b62707bc1a Tell podman to use vfs as storage-driver
Signed-off-by: Adrian Reber <areber@redhat.com>
2021-01-31 19:14:30 -08:00
Adrian Reber
41efd592ed ci: move Fedora Rawhide based tests away from Travis
This moves Fedora Rawhide based tests away from Travis. To Github
Actions for x86_64 and to Drone for aarch64.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-01-31 19:13:44 -08:00
Adrian Reber
442dc65150 ci: factor out Fedora Rawhide CI setup
To run Fedora Rawhide based aarch64 containers on Drone CI our current
Dockerfile setup does not work.

This moves the package installation out of the Dockerfile into
scripts/ci/prepare-for-fedora-rawhide.sh to be usable in the Dockerfile
environment and in the Drone CI environment.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-01-31 19:13:44 -08:00
Adrian Reber
8c89fbde39 ci: skip bpf tests on vagrant
See: https://github.com/checkpoint-restore/criu/issues/1354

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-01-31 19:12:20 -08:00
Adrian Reber
9ec1f1a7be ci: upgrade vagrant and Fedora version
The updates to the latest Vagrant version and from Fedora 32 to 33.

Also using --no-tty instead of > /dev/null for vagrant up.

Also run 'dnf upgrade -y' in out vagrant VM to get the latest kernel.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-01-29 23:01:53 -08:00
Adrian Reber
d4b0f0f948 ci: fix syntax error in stale.yml
The commas need to be inside of the quotes. Not on the outside.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-01-29 23:00:52 -08:00
Andrei Vagin
098d4cc721 zdtm: handle a case when a test vma is merged with another one
Fixes: #1346
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2021-01-29 09:08:55 -08:00
Andrei Vagin
7d63ceaecd util: zero the events pointer to avoid its double free
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2021-01-29 09:08:55 -08:00
Andrei Vagin
90f043dea7 namespaces: handle errors of snprintf
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2021-01-29 09:08:55 -08:00
Adrian Reber
76f9ccc708 ci: also use clang for compel-host-bin
Running in an environment with clang and without gcc even installed
does not work as compel-host-bin uses HOSTCC which defaults to gcc.

If CLANG=1 is set this also sets HOSTCC to clang to actually build
compel-host-bin with clang and not with gcc.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-01-29 09:07:50 -08:00
Adrian Reber
7766f12e94 ci: run aarch64 compile tests on Drone
Besides Travis CI Drone CI seems to be only service providing ARM based
builds. This switches the aarch64 and arm32 builds to drone.io.

Because Drone CI is running in a Docker container we cannot use 'setarch
linux32' as it requires the blocked syscall 'personality(2)'.

But Drone CI provides an 'arch: arm' which gives the same architecture
as 'setarch linux32' on Travis aarch64: armv8l

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-01-29 09:07:50 -08:00
Pavel Tikhomirov
af1103ff2f zdtm: cleanup thread-bomb test error handling and printing
1) Let's do test_init earlier so that max_nr test_msg is now visible in
thread-bomb.out.

2) Also lets check errors from malloc and pthread_...  functions, print
messages about their errors and do proper deallocation at least.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2021-01-29 09:06:48 -08:00
Adrian Reber
9807413c39 ci: move vagrant test to cirrus ci
With Travis dramatically reducing the minutes available for CI, CRIU
needs a new place to run tests. This moves the Vagrant based Fedora 32
no VDSO test cases to Cirrus CI. Cirrus CI seems to be one of the very
few free CI services allowing access to /dev/kvm.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-01-29 09:02:49 -08:00
Andrei Vagin
11b3a1a757 workflows/stale: Don't close issue that has labels 'new feature' or 'enhancement' 2021-01-26 00:41:05 -08:00
Andrey Zhadchenko
2cf09cc4ea fsnotify: rework redundant code
open_handle and first part of alloc_openable do the same work. Both these
function are called from check_open_handle. Rework check_open_handle to call
only alloc_openable.

Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
2021-01-24 12:43:35 -08:00
Andrey Zhadchenko
d3b1d6e0ca mount: adjust log level for mnt_is_dir
mnt_is_dir is used when looking up for suitable mount point. In some cases
that function may fail several times. Error level seems to strict for this
cases.
Added error message to lookup_mnt_sdev in case all mnt_is_dir failed.
As for open_handle and alloc_openable which are calling mnt_is_dir, they are
used in check_open_handle, which will call error afterwards.

Adjusted log level for __open_mountpoint result in open_handle since it is
allowed to fail several times. open_handle caller get_mark_path expect
possible failure and will print error in case.

Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
2021-01-24 12:43:35 -08:00