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

6324 Commits

Author SHA1 Message Date
Andrew Vagin
d35efb4abe zdtm/socket_close_data01: wait a child before c/r
A static test should not change its state during C/R.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-22 15:14:29 +03:00
Andrew Vagin
2784095aaf zdtm/sigpending: wait a child before C/R
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-22 15:13:18 +03:00
Andrey Vagin
097d0618c4 zdtm: don't hardcode file names in test soruces
Cc: Kirill Tkhai <ktkhai@odin.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Acked-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-22 14:00:29 +03:00
Cyrill Gorcunov
5ac87708a2 test: write_read10 -- Wait for children to create
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-22 11:05:52 +03:00
Cyrill Gorcunov
2529adceb5 test: write_read_10 -- Fix typo in testing opened file descriptor
Should be @child_fd instead of @fd

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-22 11:04:24 +03:00
Andrew Vagin
caeb8db5ce zdtm:mntns_open: wait when a child process opens descriptors
Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-22 11:04:16 +03:00
Andrew Vagin
7edbcdac86 zdtm/mountpoints: wait when a child process opens descriptors
Otherwise we can see this error:
5: Old files lost: set([])
5: New files appeared: set(['5', '6'])

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-21 15:54:42 +03:00
Stanislav Kinsburskiy
64d311507c files-reg: fix compilation issues
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-21 13:20:54 +03:00
Andrew Vagin
66468976c4 mountpoints: don't re-create /dev/null
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-21 12:03:39 +03:00
Pavel Tikhomirov
17c0461939 rst: set mode on ghost-files after write
Do so as in user-namespace on mainstream kernel writing to file
with suid bit set always cleares these bit, regardless to CAP_FSETID.
(see in should_remove_suid plane capable() is used, and same in VZ7)

Also we have an alternative to wait while several patches will get
in MS kernel:

[PATCH v4 0/7] Initial support for user namespace owned mounts
https://lkml.org/lkml/2015/9/23/591
[PATCH v2 12/18] fs: Don't remove suid for CAP_FSETID in s_user_ns
http://www.spinics.net/lists/linux-fsdevel/msg92533.html

Got error while suspending/resuming file_attr test in VZ7CT:
CT-102 criu# cat test/zdtm/live/static/file_attr.out
13:11:01.952: 30635: FAIL: file_attr.c:96: permissions have changed
(errno = 11 (Resource temporarily unavailable))

https://jira.sw.ru/browse/PSBM-41401
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-21 12:02:35 +03:00
Andrey Ryabinin
d0ff73077d dump: add timeout for collecting processes
Currently criu dump may hang indefinitely. E.g. in wait for task
that blocked in vfork() or task could be in D state for some other
reason. This patch adds time limit on collecting tasks during the
dump operation. If collecting processes takes too long, the dump
process will be terminated. Timeout is 5 seconds by default, but
it could be changed via parameter.

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-21 12:00:49 +03:00
Andrey Ryabinin
9bfd62c52b dump: factor out cleanup code into separate functions
This moves cleanup code from cr_dump_tasks()/cr_pre_dump_tasks()
into separte functions. No functional changes here.

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-21 12:00:10 +03:00
Andrey Ryabinin
411f639089 dump: fix return code in message on pre-dump failure
Obviously we should print pre_dump_ret value if pre-dump failed.

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-21 11:59:47 +03:00
Andrey Ryabinin
7398d9fd35 seize: slightly cleanup collect_pstree() exit path.
Use 'goto err;' everywhere. Remove 'pstree_switch_state(root_item, TASK_ALIVE)'
on error path as all collect_pstree() callers do this if collect_pstree()
failed.

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-21 11:59:40 +03:00
Dmitry Safonov
19a49e098d cr-restore: optimize {loginuid,oom_score_adj} restoring
1. Use PROC_SELF instead pid as prepare_pid_* used on restore only to
set value to current process.
2. Do not set default values.

Signed-off-by: Dmitry Safonov <dsafonov@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-21 11:58:05 +03:00
Stanislav Kinsburskiy
7f9b25bffa mount: use xsprintf() in resolve_external_mounts()
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-21 11:57:03 +03:00
Stanislav Kinsburskiy
a7e8769de3 sysfs_parse: use xsprintf() in fixup_aufs_vma_fd()
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-21 11:57:02 +03:00
Stanislav Kinsburskiy
7dd377ef0f irmap: use xsprintf() in irmap_update_dir()
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-21 11:57:01 +03:00
Stanislav Kinsburskiy
cdd2733b0a cgroup: use xsprintf() in rewrite_cgsets()
v2:
Added free of original cg->path.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-21 11:57:01 +03:00
Stanislav Kinsburskiy
696eeef6b4 mount: use xstrcat() in attach_option()
v2:
Check for empty string is simplified

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-21 11:57:00 +03:00
Stanislav Kinsburskiy
16fd19895c util: new string helpers introduced
This patch brings add_to_string() and construct_string() helpers.
They allow to create a string with variable amount of parameters in sprintf()
manner, but supporting string allocation (and reallocation if necessary)

v2:
1) Helpers were renamed to xstrcat() and xsprintf() respectively.
2) Added printf attributes to force compiler check

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-21 11:57:00 +03:00
Tycho Andersen
9c39c061ee test: block prctl in seccomp_filter
restore_creds uses prctl, so if we block this call in the seccomp filter
test, it causes things to fail (hang actually, seems we have some unhandled
error path here).

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-18 19:54:30 +03:00
Tycho Andersen
3f9179e757 pie: move seccomp before creds to avoid resoring them after setuid
Note that this doesn't actually fix the problem, because seccomp could
block the setuid call, and since we're now restoring when the task isn't
ptraced and in SECCOMP_SUSPEND mode, we can't guarantee that the seccomp
filters won't be suspended.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-18 19:54:29 +03:00
Tycho Andersen
267519c9fb test: setuid in seccomp_filter test to have it fail
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-18 19:54:28 +03:00
Andrew Vagin
1da9760dfe ptrace: start tracing processes before restoring creds
In order to restore seccomp correctly, we need to do it before
restore_creds() in the restorer blob. But, if the seccomp policy forbids
e.g. prctl, if the task doesn't have SUSPEND_SECCOMP set it will die when
trying to restore creds. To solve this, we break attach_to_tasks up into
two parts: 1. we attach and set SUSPEND_SECCOMP (but let the tasks continue
normally), and then after the RESTORE_CREDS stage we 2. attach to the tasks
and stop them on the final sigreturn.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-18 19:54:27 +03:00
Andrew Vagin
4ed47b76c6 zdtm: check shared mounts more carefully
We call mount from one namespace and umount from another namespace,
so we check that their parents are from one shared group.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-18 19:52:02 +03:00
Andrew Vagin
11bfc945dd mount: do nothing if a root mount isn't slave
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-18 19:51:48 +03:00
Andrew Vagin
b814c75295 zdtm.py: fix comparing files, maps and mounts
Now we save files, maps and mounts for each test process
and we need to compare them separately for each process.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-18 19:27:54 +03:00
Pavel Emelyanov
4e6c082970 Fix compilation after previous commit
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-18 19:16:26 +03:00
Dmitry Safonov
95cb2ddb9e files-reg: restore PR_SET_DUMPABLE flag after setfsuid
Restore dumpable flag after setfsuid to assure that created /proc/self/*
file inode had task's credentials. Without it it would have root creds
and trying to access proc files of task will fail from non-root user
in generic vfs permission check.

Signed-off-by: Dmitry Safonov <dsafonov@odin.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-18 19:08:35 +03:00
Kirill Tkhai
48b1966255 unix: Fix double restoring of peerless unix sockets, which are peers for others
Since commit ea747b075508faa5780553969d87fb21fa3c487a receive queue for
such DGRAM sockets restores twice: in open_unix_sk() and post_open_unix_sk().
It should be made only once. So, keep that commit logic only for sockets
without alive sender.

Signed-off-by: Kirill Tkhai <ktkhai@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-18 17:23:50 +03:00
Andrew Vagin
72b7351011 loginuid: save value of loginuid from a target userns
It is restored from the userns.

21:22:31.443:     4: FAIL: loginuid.c:93: loginuid value 3 is different after restore: 100003

Cc: Dmitry Safonov <dsafonov@odin.com>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Reviewed-by: Dmitry Safonov <dsafonov@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-18 17:23:04 +03:00
Tycho Andersen
9b4d7acf83 lsm: don't leak apparmor string in the case of "unconfined"
Noticed this when I was looking over the LSM code for Cyrill's task =>
thread creds set. We set this to null to save some work later, but we
forget to free it first.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-18 17:22:00 +03:00
Andrew Vagin
57f16168ed zdtm.py: tests should not inherite file descriptors from zdtm.py
Cc: Dmitry Safonov <dsafonov@odin.com>
Reported-by: Dmitry Safonov <dsafonov@odin.com>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Tested-by: Dmitry Safonov <dsafonov@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-18 16:54:07 +03:00
Dmitry Safonov
4a393715af seize: do not try to detach killed tasks
unseize_task_and_threads sends SIGKILL in unseize_task under condition
(st == TASK_DEAD). Which obviously kills task.

Move freezer_detach after pstree_wait to detach only from alive tasks
to get rid of the following errors:
	(00.242163) Error (seize.c:223): Unable to detach from 23064
	: No such process
	(00.242177) Error (seize.c:223): Unable to detach from 23065
	: No such process

Signed-off-by: Dmitry Safonov <dsafonov@odin.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-17 15:40:00 +03:00
Dmitry Safonov
d58f6b705e zdtm: Change oom_score_adj score value
... so it can be used from non-root:
(Higher value means it would be killed earlier so everyone should be
possible to change his value to bigger than zero)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-16 18:42:17 +03:00
Stanislav Kinsburskiy
6663cae781 files: check fd flags after restore
System call sys_fcntl() in _some_ kernels can silently drop some flags during
set and return success code.
This patch adds double check, that all the fd flags were really set.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-16 18:22:50 +03:00
Evgeniy Akimov
8b04551c48 restore: restore freezer cgroup state
Patch restores freezer cgroup state between finalize_restore stages.
It should be done after first stage because we cannot unmap restorer blob
from frozen process, and before second stage because we must freeze processes
before they continue run.
We also need to move fini_cgroup between these stages to provide freezer
cgroup state restorer access to cgroup mount directories.
Error handlers contains fini_cgroup, so we are sure that fini_cgroup call
won't be missed.

Patch restores state only for one freezer cgroup from --freeze-cgroup option,
not all states from whole hierarchy, because CRIU supports checkpoint from
freezer cgroup hierarchy only with THAWED state, except root cgroup from
--freeze-cgroup option.

Signed-off-by: Evgeniy Akimov <geka666@gmail.com>
Signed-off-by: Eugene Batalov <eabatalov89@gmail.com>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-16 18:17:04 +03:00
Evgeniy Akimov
b3e5cf75db restore: split finalize_restore into two stages
First stage of finalize_restore unmaps the restorer blob, second stage
detaches from processes. After first stage process tree is completely
restored and processes are ready to continue run through sigreturn.
This splitting allows us to execute something between these stages (e.g.
restore freezer cgroup state).

Signed-off-by: Evgeniy Akimov <geka666@gmail.com>
Signed-off-by: Eugene Batalov <eabatalov89@gmail.com>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-16 18:17:03 +03:00
Evgeniy Akimov
34662a68c8 cgroups: save freezer state during dump
CRIU sets freezer.state to "THAWED" during process tree dumping. That's why
we can't simply save freezer.state file contents to cgroups image. New
special function get_real_freezer_state() returns freezer cgroup state
observed before CRIU dumping start. Patch puts its return value to dump file.

Signed-off-by: Evgeniy Akimov <geka666@gmail.com>
Signed-off-by: Eugene Batalov <eabatalov89@gmail.com>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-16 18:17:01 +03:00
Pavel Emelyanov
25a978d32e crit: The 'mems' explorer
This one prints the /proc/pid/maps-like output, but with slightly more
details. Like this

1
	exe                                     /zdtm/live/static/maps00
	00400000-00406000                   r-x /zdtm/live/static/maps00
	00605000-00606000                   r-- /zdtm/live/static/maps00 + 0x5000
	00606000-00607000                   rw- /zdtm/live/static/maps00 + 0x6000
	7f4037845000-7f40379f9000           r-x /lib64/libc.so.6
	7f40379f9000-7f4037bf8000           --- /lib64/libc.so.6 + 0x1b4000
	7f4037bf8000-7f4037bfc000           r-- /lib64/libc.so.6 + 0x1b3000
	7f4037bfc000-7f4037bfe000           rw- /lib64/libc.so.6 + 0x1b7000
	7f4037bfe000-7f4037c03000           rw-
	7f4037c03000-7f4037c23000           r-x /lib64/ld-linux-x86-64.so.2
	7f4037e1e000-7f4037e22000           rw-
	7f4037e22000-7f4037e23000           r-- /lib64/ld-linux-x86-64.so.2 + 0x1f000
	7f4037e23000-7f4037e24000           rw- /lib64/ld-linux-x86-64.so.2 + 0x20000
	7f4037e24000-7f4037e25000           rw-
	7fff34652000-7fff34699000           rw- [stack?]
	7fff346e2000-7fff346e4000           r--
	7fff346e4000-7fff346e6000           r-x [vdso]
	ffffffffff600000-ffffffffff601000   r-x [vsyscall] *

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-16 18:14:57 +03:00
Pavel Emelyanov
6c8f7bbb29 crit: The 'fds' explorer
Shows files opened by tasks. The output is like

1
	      0: /dev/null
	      1: /zdtm/live/static/session00.outns
	      2: /zdtm/live/static/session00.outns
	    cwd: /zdtm/live/static
	   root: /
6
	      0: /dev/null
	      1: /zdtm/live/static/session00.out.inprogress
	      2: /zdtm/live/static/session00.out.inprogress
	      3: pipe[18305]
	    cwd: /zdtm/live/static
	   root: /
10
	      0: /dev/null
	      1: /zdtm/live/static/session00.out.inprogress
	      2: /zdtm/live/static/session00.out.inprogress
	      3: pipe[18308]
	    cwd: /zdtm/live/static
	   root: /

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Appreciated-by: avagin@openvz.org
2015-12-16 18:14:56 +03:00
Pavel Emelyanov
022baf868b crit: The 'ps' explorer
Shows process tree from image. The output is like

    PID   PGID    SID   COMM
      1      1      1   session00
      4      4      4       session00
      7      7      7           session00
      8      4      4           session00
     11     11     11           session00
     12      4      4               session00
     13     13     13           session00
     14     14     14               session00
     15      4      4                   session00
      6      4      4       session00
     10      9      9       session00

(the above is for session00 test).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Appreciated-by: avagin@openvz.org
2015-12-16 18:14:55 +03:00
Pavel Emelyanov
075c1c9f08 crit: Explore action and stubs
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Appreciated-by: avagin@openvz.org
2015-12-16 18:14:54 +03:00
Andrew Vagin
dcd750a64f zdtm.py: bind-mount a test root as slave
In this case it has an external master_id and we want to test that
criu can handle it correctly.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-16 18:13:55 +03:00
Andrew Vagin
cba08fb788 makefile: use zdtm.py to execute tests
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-16 18:13:31 +03:00
Andrew Vagin
4986d1b51e zdtm.py: compare a set of mounts before and after c/r
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-16 18:13:03 +03:00
Andrew Vagin
36216c3c1b zdtm.sh: fix a value of ZDTM_THREAD_BOMB
The thread_bomb test was rewrited and
ZDTM_THREAD_BOMB should be equal 5 now.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-16 18:12:32 +03:00
Andrew Vagin
276eb6e823 zdtm.py: don't mix tab and spaces
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-16 18:12:07 +03:00
Andrew Vagin
3eac44ae85 zdtm.py: collect fds and maps for all test processes
It works for tests which are executed in a separate pidns

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-16 18:11:44 +03:00