2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 13:58:34 +00:00

9606 Commits

Author SHA1 Message Date
Adrian Reber
222ad25bed Makefiles: auto-detect python version - prefer python2
This prepares CRIT for python2/python3 compatibility by auto-detecting
the installed python version. python2 is detected first and then the
variable PYTHON is set.

By setting the variable PYTHON to python2/python3 the user can override
the auto-detection.

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-25 00:23:00 +03:00
Adrian Reber
af353d0f69 crit: make crit python2/python3 compatible
Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-25 00:23:00 +03:00
Andrei Vagin
049b1444b3 remote: a few minor fixes to make travis happy 2018-05-23 03:13:25 +03:00
Rodrigo Bruno
d4a21d98e0 remote: Fixing identation. 2018-05-23 03:13:25 +03:00
Rodrigo Bruno
cc4cc0750c remote: Minor improvements on img-remote.c 2018-05-23 03:13:25 +03:00
Rodrigo Bruno
cb5f93675a remote: Unblocking implementation of img cache and proxy seems to be working. 2018-05-23 03:13:25 +03:00
Rodrigo Bruno
945875fcea remote: Unix socket for local connections is async. 2018-05-23 03:13:25 +03:00
Rodrigo Bruno
7c81eeb9ba remote: Preparing image receive and send for asynchronous sockets. 2018-05-23 03:13:25 +03:00
Dmitry Safonov
82a891b73a Documentation/make: Call check before install
Let's warn about binary needed for `install` target.
Before:
[root@localhost criu]# make install
  GEN      crit.1
make[1]: *** [Makefile:49: crit.1] Error 127
make: *** [Makefile.install:32: install-man] Error 2

After:
[root@localhost criu]# make install
/bin/sh: line 1: xmlto: command not found
make[1]: *** [Makefile:32: check] Error 1
make: *** [Makefile.install:32: install-man] Error 2

Fixes: #481
Reported-by: treaki@gmail.com
Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-18 01:23:17 +03:00
Dmitry Safonov
0af80816de zdtm/make: Include Makefile.inc after defining $(DEP)
Otherwise, tests dependencies are not considered for build.
Add an error in Makefile.inc so this won't happen again.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Reported-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-18 01:23:17 +03:00
Dmitry Safonov
c4848ffeed Revert "test/make: Include .d files"
This reverts commit dcafa78b96084216e32b757be62b7fa8aebbdd87.

I've found that we already include deps in Makefile.inc,
was to fast on the first attempt and overlooked this.
(the include just doesn't work like it should yet..)

The origin patch may be just dropped before preparing master's merge.

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-18 01:23:17 +03:00
Cyrill Gorcunov
267899bfb6 unix: Improve init_unix_sk_info
This helper must init every member of a structure,
not some part of it. Beautify code as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 21:53:34 +03:00
Cyrill Gorcunov
04e28419e5 unix: Unify printings on peer open
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 21:53:34 +03:00
Cyrill Gorcunov
015e1aca3f unix: Print reverted dir info if only directory provided
Otherwise there is an imbalance in logs with number of
"Reverted working dir" message

 | (00.018604)     36: unix: Connected 0x11ceff -> 0x11cf00 (0x11cf00) flags 0
 | (00.018644)     36: unix: Reverted working dir
 | (00.018652)     36: unix: Connected 0x11cefd -> 0x11cefe (0x11cefe) flags 0
 | (00.018665)     36: unix: Reverted working dir
 | (00.018688)     36: unix: Reverted working dir

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 21:53:34 +03:00
Cyrill Gorcunov
e114ede3ad unix: Don's spam with warning if nothing to unlink
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 21:53:34 +03:00
Cyrill Gorcunov
d8e2b48d10 unix: Drop empty line at eof
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 21:53:34 +03:00
Cyrill Gorcunov
6824331903 unix: Use generic xptr_pull in dump_one_unix_fd
To unify style of pointers fetching from memory slab.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 21:53:34 +03:00
Cyrill Gorcunov
1a07226146 unix: Adjust unix_desc_ops members
For readability sake.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 21:53:34 +03:00
Cyrill Gorcunov
451cad336b unix: Adjust unix_sk_cinfo members
For readability sake.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 21:53:34 +03:00
Cyrill Gorcunov
018673694b unix: Adjust unix_sk_info members
For readability sake. And use standart uint8_t types.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 21:53:34 +03:00
Cyrill Gorcunov
a7f6f2513d unix: Use uint32_t instead of u32
So the rest of code will match.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 21:53:34 +03:00
Cyrill Gorcunov
c7b9895567 unix: Use one word log prefix
For grep sake.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 21:53:34 +03:00
Cyrill Gorcunov
89c9ec7f2f arch, ppc64: Add missing atomic_dec_and_test helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 21:53:34 +03:00
Cyrill Gorcunov
73d015e8d9 seccomp: Fix building issue on recent kernels
The seccomp_metadata may be already defined in
system ptrace.h header on recent kernels so
include it.

https://github.com/checkpoint-restore/criu/issues/486#event-1628406918

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 20:57:42 +03:00
Cyrill Gorcunov
0b0ed6b804 mem: Fix typo in detect_pid_reuse
*** CID 190172:  Uninitialized variables  (UNINIT)
/criu/mem.c: 325 in detect_pid_reuse()

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 20:57:42 +03:00
Cyrill Gorcunov
65e8d733da seccomp: Fix typo in collect_filters
*** CID 190178:  Null pointer dereferences  (NULL_RETURNS)
/criu/seccomp.c: 296 in collect_filters()

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 20:56:49 +03:00
Andrei Vagin
74bd63b3b9 sk-unix: don't pass a negative value to close()
CID 190174 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
6. negative_returns: fd is passed to a parameter that cannot be negative.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 20:55:55 +03:00
Andrei Vagin
2c88d783ea dump: remove dead code
CID 190175 (#1 of 1): Logically dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement: goto err;.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 20:55:54 +03:00
Andrei Vagin
15f07608a3 action-scripts: check a return code of get_service_fd
>>>     CID 190177:  Integer handling issues  (NEGATIVE_RETURNS)
>>>     rpc_sk is passed to a parameter that cannot be negative.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 20:55:54 +03:00
Andrei Vagin
2f84ed54a7 tun: don't leak a file descriptor
CID 84654 (#1 of 1): Resource leak (RESOURCE_LEAK)
6. leaked_handle: Handle variable fd going out of scope leaks the handle.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 20:53:51 +03:00
Andrei Vagin
e0a0e1b7fa pie/log: print space after timestamp
(00.566486)pie: 1: seccomp: mode 0 on tid 1

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 08:42:36 +03:00
Mike Rapoport
b4d4eaf212 lazy-pages: replace crappy num_children with simple reference counting
The purpose of the num_children field in 'struct lazy_pages_info' was to
prevent closing the page-read while there are still active processes that
share it. It did work for the case when handling of the child processes
finished before the parent process. However, if the parent lpi is closed
first, we've got a dangling pointer at lpi->parent.
The obvious solution is to use simple reference counting.

Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 08:41:19 +03:00
Mike Rapoport
0cfc235a30 lazy-pages: reset poll_timeout to 0 as soon as restore is finished
It is possible that notification about restore finish arrives at the same
time with a fork event. In such case we return to epoll_run_rfds without
resetting the poll_timeout and then we'll keep polling for events
indefinitely. To avoid this, we reset the poll_timeout to 0 as soon as we
know that restore is finished.

Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 08:41:19 +03:00
Mike Rapoport
43da190cfc lazy-pages: handle_exit: set uffd to negative value instead of 0
The only use for the userfault file descriptor after the process exited is
for debug logs. Using negative value instead of 0 makes logs more readable.

Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 08:41:19 +03:00
Mike Rapoport
c23f16c28a lazy-pages: use xfree() instead of free()
Although they are the same, xfree() looks more consistent with other code

Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 08:41:19 +03:00
Andrey Vagin
4fb0935f54 compel/log: increase a max line length
There are a lot of lines, which are longer than 79:

(04.331172)pie: 1: Error (criu/pie/restorer.c:460): seccomp: Unexpected tid ->
(04.331172)pie: 1: 1 != 1

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 08:32:34 +03:00
Andrey Vagin
7c74f41ab7 zdtm: don't print one line twice
(00.566486)pie: 1: seccomp: mode 0 on tid 1
(00.566601)pie: 1: Error (criu/pie/restorer.c:460): seccomp: Unexpected tid ->
(00.566601)pie: 1: 1 != 1
(00.566601)pie: 1: 1 != 1
(00.566639)pie: 1: Error (criu/pie/restorer.c:1817): Restorer fail 1

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 08:27:17 +03:00
Andrey Vagin
e3ce31257f restore: check a return code of RUN_CLONE_RESTORE_FN
Otherwise we can skip an error and then criu will hang on switching to
the next stage.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 08:26:57 +03:00
Cyrill Gorcunov
e85799de68 seccomp: Move changed ptrace flags setup after creds
Credential commitment affects dumpable and pdeath signals
so we have to move their restore after the restore_creds,
just like we have in __export_restore_task (ie for
group leader).

https://jira.sw.ru/browse/PSBM-84198

Acked-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 08:25:19 +03:00
Cyrill Gorcunov
b44d39ba5d zdtm: Don't fail in __construct_root if entries exist
Otherwise we might get

 | OSError: [Errno 17] File exists: '/tmp/criu-root-f8klhI/bin'
 |     os.symlink(".." + ldir, self.root + "/usr" + ldir)
 | OSError: [Errno 17] File exists
 |  File "zdtm.py", line 209, in __mknod
 |     os.mknod(name, stat.S_IFCHR, rdev)
 | OSError: [Errno 17] File exists

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 08:23:06 +03:00
Andrei Vagin
a77d172d1e kdat: fill kdat by zero-s before initializing it
kerndat_try_load_cache() fills kdat from /run/criu.kdat,
so it will contain some trash, if criu.kdat isn't compatible with the
current version of criu.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 00:51:12 +03:00
Cyrill Gorcunov
2d27a43300 seccomp: Don't lookup for pidns in restore_seccomp
Looking up for pid in nesting pidns supposed to be done
for non group leaders only, thus __export_restore_thread
do this check on its own and we don't have to make
a similar lookup especially on group leader where
pids in args never were valid.

Reported-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-15 19:17:41 +03:00
Cyrill Gorcunov
8340e64137 seccomp: Fix nits in collect_filter
- Fix typo in sizeof() operand
 - Eliminate redundant prctl calls if no PTRACE_SECCOMP_GET_METADATA
   detected

Reported-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-15 03:51:16 +03:00
Cyrill Gorcunov
cf74c9fed3 seccomp: test, seccomp_filter_threads -- Use multiple threads
Andrew proposed the test which actually triggered the issue
in current seccomp series, put it into a regular basis.

Suggested-by: Andrey Vagin <avagin@virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-15 03:51:16 +03:00
Cyrill Gorcunov
064cafa80c seccomp: Dont forget to suspend filtering on threads
When considering if we to call PTRACE_O_SUSPEND_SECCOMP
on the tid we should take into account if there at least
one thread which has seccomp mode enabled, otherwise
we might miss filter suspension and restore procedure
might break due to own criu syscall get filtered out.

Same time we should move seccomp restore for threads
to take place after CR_STATE_RESTORE_SIGCHLD state
so that main criu code will attach to threads and
setup seccomp suspension flag before we start
restoring the filters.

Reported-by: Andrei Vagin <avagin@virtuozzo.com>
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-15 03:51:16 +03:00
Cyrill Gorcunov
e91c3a8335 seccomp: test -- Add seccomp_filter_threads
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-15 03:51:16 +03:00
Cyrill Gorcunov
204bcba38b seccomp: Add engine to checkpoint per-thread seccomp chains
To checkpoint per-thread seccomp filters we need
a significant rework of a dumping code. The general
idea is the following:

 - Each thread is tracked by its tid inside global
   seccomp rbtree thus we can easily add entries
   there or lookup on demand.

 - When we collect threads into pstree entries we fetch
   its seccomp mode from procfs parsing routine and allocate
   a new entry inside rbtree to remember the seccomp mode.
   Note at this moment we're not dumping real filters yet
   (because filter data image is a single one for all consumers)

 - Once all tids are collected and our tree is complete we call for
   seccomp_collect_dump_filters helper which walks every pstree entry
   and iterate over each tid inside thread group calling
   seccomp_dump_thread, which in turn uses ptrace engine to fetch
   filters and keep this data in memory.

   To optimize data usage we figure out if we can use TSYNC flag
   on restore calling try_use_tsync helper: for TSYNC flag kernel
   automatically propagate filter to all threads, thus we need to
   compare all filters inside thread group for identity since there
   is no other way to figure out if user passed TSYNC flag when
   been creating filters.

  - Finally dump_seccomp_filters is called which does real write
    of seccomp filter data into an image file.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-15 03:51:16 +03:00
Cyrill Gorcunov
ffa54cfb1d seccomp: Add engine to restore per-thread seccomp chains
At now we pretend that all threads are sharing seccomp chains
and at checkpoint moment we test seccomp modes to make sure
if this assumption is valid refusing to dump otherwise.

Still the kernel tacks seccomp filter chains per each thread
and now we've faced applications (such as java) where per-thread
chains are actively used. Thus we need to bring support of handling
filters via per-thread basis.

In this a bit intrusive patch the restore engine is lifted up
to treat each thread separately. Here what is done:

 - Image core file is modified to keep seccomp filters
   inside thread_core_entry. For backward compatibility
   former seccomp_mode and seccomp_filter members in
   task_core_entry are renamed to have old_ prefix and
   on restore we test if we're dealing with old images.

   Since per-thread dump is not yet implemeneted the
   dumping procedure continue operating with old_ members.

 - In pie restorer code memory containing filters are addressed
   from inside thread_restore_args structure which now
   contains seccomp mode itself and chain attributes
   (number of filters and etc).

   Reading of per-thread data is done in seccomp_prepare_threads
   helper -- we take one pstree_item and walks over every thread
   inside to allocate pie memory and pin data there.

   Because of PIE specific, before jumping into pie code
   we have to relocate this memory into new place and
   for this seccomp_rst_reloc is served.

   In restorer itself we check if thread_restore_args provides
   us enabled seccomp mode (strict or filter passed) and call
   for restore_seccomp_filter if needed.

 - To unify names we start using seccomp_ prefix for all related
   stuff involved into this change (prepare_seccomp_filters renamed
   to seccomp_read_image because it only reads image and nothing
   more, image handler is renamed to seccomp_img_entry instead
   of too short 'se'.

With this change we're now allowed to start collecting and
dumping seccomp filters per each thread, which will be
done in next patch.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-15 03:51:16 +03:00
Cyrill Gorcunov
06626522d1 seccomp: Fetch seccomp flags if kernel provides
Note that there is no real usage of this flag on restore,
we simply save it in image and will make a real use
later.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-15 03:51:16 +03:00
Cyrill Gorcunov
4776079e0b seccomp: Move seccomp_info into seccomp.h
This header is main place for all seccomp related
structures so move seccomp_info here. This will
allow to minimize changes area when need to update
definitions and such.

Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-15 03:51:16 +03:00