2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00
Commit Graph

6324 Commits

Author SHA1 Message Date
Andrew Vagin
4c00ac2908 lock: print a message if a futex is locked for more than 120 second
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 10:52:22 +03:00
Tycho Andersen
bff121032d test: add a test for seccomp filter inheritance
v2:
 * add another filter to the chain to test the inheritance chaining check
 * include zdtm.py desc file

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 10:51:24 +03:00
Tycho Andersen
91de2a4701 test: add a test for SECCOMP_FLAG_FILTER_TSYNC
v2: include zdtm.py desc file

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 10:51:23 +03:00
Tycho Andersen
ccbcc5efb3 test: Add a test for c/r of seccomp filters
v2: include zdtm.py desc file

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 10:51:22 +03:00
Tycho Andersen
5e2ca506e4 check: add a check for seccomp filters c/r
v2: use a non-racy version of fork_and_ptrace_attach

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 10:51:21 +03:00
Tycho Andersen
221af18ea0 seccomp: add support for SECCOMP_MODE_FILTER
This commit adds basic support for dumping and restoring seccomp filters
via the new ptrace interface. There are two current known limitations with
this approach:

1. This approach doesn't support restoring tasks who first do a seccomp()
   and then a setuid(); the test elaborates on this and I don't think it is
   tough to do, but it is not done yet.

2. Filters are compared via memcmp(), so two tasks which have the same
   parent task and install identical (via memory) filters will have those
   filters considered to be the "same". Since we force all tasks to have
   the same creds (including seccomp filters) right now, this isn't a
   problem.

The approach used here is very similar to the cgroup approach: the actual
filters are stored in a seccomp.img, and each task has an id that points to
the part of the filter tree it needs to restore. This keeps us from dumping
the same filter multiple times, since filters are inherited on fork.

v2:
 * remove unused seccomp_filters field from struct rst_info
 * rework memory layout for passing filters to restorer blob
 * add a sanity check when finding inherited filters

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 10:51:20 +03:00
Andrew Vagin
1a86283bfb tty: open all terminals with O_NOCTTY
Otherwise the kernel can set it as a control terminal for the currect
session and CRIU will not be able to set it as a control terminal for
the target process.

Reported-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 10:48:56 +03:00
Andrew Vagin
bea76a01bb proc_parse: don't parse the same line in a second time
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 10:47:11 +03:00
Andrew Vagin
798e44cf7e dump: add missing new line in message
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 10:46:22 +03:00
Andrew Vagin
b78af1923b mount: wait when mntns will be created to get its root (v2)
v2: add comments and rename ns_created to ns_populated.

Reported-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 10:46:00 +03:00
Andrew Vagin
322655fbbc pstree: set ids for helpers
It can be the same with a parent one and the helper will inherit all
parent resources.

Now we can dereference item->ids for all task. It's used in
restore_task_mnt_ns, for example.

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 10:45:11 +03:00
Andrew Vagin
e95fd98b12 restore: call close_old_fds() before forking children
If processes share a file descriptor table, they all have their own set
of service descriptors. close_old_fds() closes all file descriptors
execpt service descriptors

Fixes: 9d60724eca ("restore: restore mntns before creating private vma-s (v3)")
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 10:45:10 +03:00
Andrew Vagin
7017181849 mount: don't inherit mount namespace descriptors to each process
close_olds_fds() knows nothing about more than one set of service file
descriptros, so it's better to call it before forking children as it was
bedore 9d60724eca ("restore: restore mntns before creating private vma-s")

The root task restores all processes and pin them with file descriptors,
then a task restores a mount namespace by opening the file descriptor of
the root task via /proc/pid/fd/X.

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 10:45:09 +03:00
Andrew Vagin
9d60724eca restore: restore mntns before creating private vma-s (v3)
We need to open a file to restore a file mapping and this file
can be from a current mntns.

v2: All namespaces are resotred from the root task and then
other tasks calls setns() to set a proper mntns.

v3: fix comments from Pavel
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-14 09:53:47 +03:00
Cyrill Gorcunov
04f7131ad3 tty: Restore controlling terminal once per session
There might be several same terminals opened (say
tty6 or whatever) which gonna look as separate
files but actually pointing to the same tty kernel
instance. Moreover if it's a controlling terminal
we will be trying to restore it as many times as
find non zero sid on a peer.

Instead lets do a simple trick first: choose a leader
from a terminal group and use it only for controlling
terminal restoration.

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

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: Andrew Vagin <avagin@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-13 20:00:33 +03:00
Andrew Vagin
8796b18eba files: linkat_hard() should return errno of linkat
errno is used in open_path()

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-13 19:59:07 +03:00
Andrew Vagin
0b4fecca62 zdtm: check an unlinked file when a file with the save name exists
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-13 19:59:01 +03:00
Andrew Vagin
138d2631ee zdtm: add a new test to check tmpfs in a non-root mntns (v2)
v2: add a file mapping from a test tmpfs mount
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-13 19:52:42 +03:00
Andrey Ryabinin
947dcc736f mount: use correct mount namespace in open_mountpoint
open_mountpoint() have to operate in target's mount namespace,
which may differ from root's namespace - root_item->pid.real.

So obtain the correct mount namespace from mount_info and use
it in switch_ns().

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-13 19:52:08 +03:00
Pavel Emelyanov
bada292932 zdtm.py: Fix race in root construction
If two ns_flavor.init() are called in parallel then all the os.mkdir()
calls would end up with EEXISTS exception.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-13 15:16:56 +03:00
Pavel Emelyanov
a96320604b zdtm.py: Do not run tests marked with excl in parallel (v2)
There are tests (e.g. on locks) that can conflict with each other, so
wait for all the other jobs to finish before running such.

v2:
  Wait for the excl test to finish before launching more of them.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-13 15:16:36 +03:00
Pavel Emelyanov
65408e927f page-read: Fix compilation on arm (2)
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 23:51:15 +03:00
Pavel Emelyanov
efb31988ec page-read: Fix compilation on arm
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 23:27:57 +03:00
Andrey Vagin
a9e5d2b417 jenkins: fix path to report
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 22:32:06 +03:00
Andrew Vagin
25eb3d6db2 jenkin: mark all scripts as executalbe
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 20:59:07 +03:00
Pavel Emelyanov
a6cb3d782d jenkins: Do not test cgroup02 with --norst
This test expects that it _will_ be C/R-ed into new hierarchy

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 17:16:52 +03:00
Pavel Emelyanov
127152268a jenkins: Make criu-snap test use zdtm.py
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 18:11:38 +04:00
Pavel Emelyanov
cc378b909a jenkins: Make criu-dump test use zdtm.py
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 18:01:37 +04:00
Pavel Emelyanov
dc00fea333 net: Dont print error in rule save
This thing is new and can be absent in ip tool, which is OK
and is handled by net.c code itself.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 16:31:21 +03:00
Pavel Emelyanov
336b990995 net: Add flags to run_ip_tool
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 16:31:20 +03:00
Pavel Emelyanov
18d9170858 util: Add flags to cr_system
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 16:31:19 +03:00
Pavel Emelyanov
e5a91658c5 zdtm: Do not create dangling executables
Otherwise they are left after test and make zdtm.py list thing
these files are tests too.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 16:30:44 +03:00
Pavel Emelyanov
9a366728bc zdtm: Make /dev/net/tun optional device in test ns
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 16:30:44 +03:00
Andrew Vagin
79be3677bc zdtm: don't execute the bridge test from zdtm.sh
zdtm.sh doesn't suppport dependencies. This test uses the ip tool.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 16:24:04 +03:00
Pavel Emelyanov
37ec967643 jenkins: Move pre-dump test on .py launcher
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 15:58:44 +03:00
Pavel Emelyanov
7d72537dbd page-read: Properly handle overlapping pagemaps in stack
If the pagemap we read at some point covers two (or more) pagemaps
in parent images, we cannot just call the parent page read for all
those pages. Instead, we must call parent page read with shorter
requests so that it handles its own pagemaps properly.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 15:58:43 +03:00
Andrew Vagin
87c0376b60 zdtm: execute the bridge test in a new netns only
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 15:25:24 +03:00
Pavel Emelyanov
446a8ba857 jenkins: Exclude maps04 from -sibling test
This guy runs on tmpfs for dumps and maps04 is too heavy for it

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 15:15:47 +03:00
Cyrill Gorcunov
fa0587ed81 restore: Use min_t helper for type casting
On arm

 | CC       crtools.o
 | In file included from arch/arm/include/asm/bitops.h:4:0,
 |                  from arch/arm/include/asm/types.h:9,
 |                  from include/proc_parse.h:5,
 |                  from include/ptrace.h:8,
 |                  from cr-restore.c:27:
 | cr-restore.c: In function 'restore_priv_vma_content':
 | include/compiler.h:60:17: error: comparison of distinct pointer types lacks a cast [-Werror]
 |   (void) (&_min1 == &_min2);  \
 |

Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 14:57:05 +03:00
Cyrill Gorcunov
ee2409ec37 compiler: Grab min_t, max_t from the kernel
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 14:57:00 +03:00
Andrew Vagin
23a2472ccb test: use the ip tool instead of ifconfig and brctl
I'm too lazy to install new tools on all test hosts.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 14:08:16 +03:00
Cyrill Gorcunov
c63a42ac2f restore: Use bitmap_set helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 11:15:13 +03:00
Cyrill Gorcunov
ba475b8dcf bitmap -- Add few helpers for bits manipulations
Grabbed from kernel. Probably worth to gather
all bits manipulators here in future.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 11:15:02 +03:00
Pavel Emelyanov
03b217c0a6 restore: Restore as many pages at once as possible
When the VMA being restored is not COW-ed we read pages from images
one-by-one which results in suboptimal pages.img access. Fix this
by reading as many pages from iamge at once as possible withing the
active pagemap and VMA.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 11:14:44 +03:00
Pavel Emelyanov
780d699401 page-read: Teach page-read to read multiple pages at once
This is preparatory patch, the problem to solve is described in
the next one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 11:14:43 +03:00
Tycho Andersen
e41f4dbcab gitignore: ignore a bunch of other generated stuff
Some test binaries weren't ignored, and some of the new zdtm.py files.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 10:32:27 +03:00
Tycho Andersen
34f33bd7ba tests: add a test for c/r of an empty bridge
v2: * add a zdtm.py .desc file
    * only look to make sure inet addresses match (in particular, don't
      match the state)

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 10:32:24 +03:00
Tycho Andersen
8a95be0679 net: allow c/r of empty bridges in the container
Implementing c/r of bridges with slaves shouldn't be too hard (viz. the
comment), but this is all I need to for right now.

v2: remove extra debug statement
v3: * remember to close fd in dump_bridge
    * use "known" buffer length and snprintf for spath in dump_bridge
    * change brace style

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-12 10:31:58 +03:00
Pavel Emelyanov
b67bde83bb collect: Print info about collection finish
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-11 19:03:09 +03:00
Tycho Andersen
a0470e9bd9 add seccomp syscall
We'll use this when restoring eBPF programs in FILTER mode.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-11 15:57:27 +03:00