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

3753 Commits

Author SHA1 Message Date
Andrey Vagin
1009c8bb50 iptables: use cr_system instead of system
We are going to detect parasite crashes. For that we are goint to check
all unwaited processes in SIGCHLD handler.

cr_system blocks SIGCHLD and unblocks it after waiting a target process.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-02 20:09:37 +04:00
Andrey Vagin
29c3e84234 parasite: the type of the communication socket must be SOCK_SEQPACKET
We use unix socket to communicate with parasite. Before we used
SOCK_STREAM, but it doesn't guaranty that the message boundaries will be
save.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-02 20:08:39 +04:00
Pavel Emelyanov
229e4e502d security: Check not only real user ID
When dumping/restoring for unpriveledged user, check for all
sets of IDs to match, just like ptrace-may-attach in the kernel.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 16:43:25 +04:00
Pavel Emelyanov
b4c8c5ae32 security: Also save gid of user requesting for C/R
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 15:51:09 +04:00
Pavel Emelyanov
6bf63b3f01 security: Push full creds info into may_xxx checks
It's not enough to check only uids on dump and restore -- we need to
check e-ids and s-ids now (and caps in the future).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 15:48:44 +04:00
Ruslan Kuprieiev
547d9bf959 v2 security: set suid flag on crtools and check real uid on dump/restore
v2: remove redundant functions and variables.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-02 17:11:17 +04:00
Ruslan Kuprieiev
398705d4cb rpc: rename criu_dump_req to criu_opts
Lets rename CriuDumpReq to CriuOpts, for the sake of readability and to
avoid coping code for restore mechanism, as CriuDumpReq and
CriuRestoreResp would have almost the same fields. Also, it would be
easier to introduce other types of requests.

Signed-off-by: Ruslan Kuprieiev <kurpuser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-02 16:04:11 +04:00
Ruslan Kuprieiev
4d80f502e8 v2 rpc: add log_file field to opts, add defaults toi log.h and use them where needed
[xemul: Simplified !log_file case and renumbered .proto fields]

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-02 16:01:44 +04:00
Ruslan Kuprieiev
9907302823 dump: initilize vmas in the very beginning
When dump/pre-dump failed before initializing vmas, free_mappings(&vmas)
is called and this cause segfault. Lets initialize vmas in the very
beginning of dump.

Signed-off-by: Ruslan Kuprieiev <kurpuser@gmail.com>

seqfault.patch
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-02 13:27:32 +04:00
Andrey Vagin
bd8876d2d1 zdtm: fix syntax error in zdtm.sh
./zdtm.sh: line 231: local: `lname,': not a valid identifier
./zdtm.sh: line 251: local: `ldir,': not a valid identifier

https://bugzilla.openvz.org/show_bug.cgi?id=2763
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 23:44:04 +04:00
Pavel Emelyanov
4b9b7953dd service: Make default (not set) service ino == -1
Zero is bad for checks, as peer-less sockets have such.
BUG introduced in cfe72ab7 :(

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 09:44:29 +04:00
Pavel Emelyanov
e8f4840049 dump: Add some comments to tasks collecting code
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 06:28:33 +04:00
Pavel Emelyanov
2fe5884df3 service: Remove empty cr_service_client
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 06:18:44 +04:00
Pavel Emelyanov
91389f8782 security: Introduce (rather basic) security restrictions for C/R
Right now we have an ability to launch the C/R service from root
and execure dump requests from unpriviledged users. Not to be bad
guys, we deny dumping tasks belonging to user, that cannot be
"watched" (traced, read /proc, etc.) by the dumper.

In the future we will use this "engine" when launched with suid
bit, and (probably) will have more sophisticated policy.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 06:16:17 +04:00
Pavel Emelyanov
cfe72ab77a service: Put service sk inode into separate variable
I'm about to get rid of service state struct.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 06:06:53 +04:00
Pavel Emelyanov
14559435f5 service: Sanitize service-child code-flow
* Close fd only once at the end
* Close listener socket

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 05:59:33 +04:00
Pavel Emelyanov
0acc2624d4 service: Remove sk fd from service state struct
This fd is an internal thing of the service. Remove it from
externally available structure.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 05:54:50 +04:00
Pavel Emelyanov
0521367f22 service: Remove actually unused pid variable from service state
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 05:52:18 +04:00
Pavel Emelyanov
9bc82f4910 rpc: Send EMPTY message with success == fail in case of unsupported request
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 05:49:31 +04:00
Pavel Emelyanov
0327d5511b fdset: Beautify fdset opening
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 05:39:52 +04:00
Pavel Emelyanov
02227d879f ns: Extend ns dumping log messages with ids and pids
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 05:32:52 +04:00
Andrey Vagin
891acca97f ns: dump all namespaces
Before this patch only namespaces of the root task are dumped.
Now we dump all namespace, which have been collected.

I'm not sure, that we want to create a new process for each namespace.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:19:21 +04:00
Andrey Vagin
36d8c40c44 namespace: add real pid to nsid
Before we dumped namespace of the root task only.
Now we are going to dump nested namespaces, so we need to know a pid of
any process, which lives in the target namespace.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:19:19 +04:00
Andrey Vagin
07930a8df4 ns: replace pid on id in per-namespace files
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:17:04 +04:00
Andrey Vagin
51fca3806c namespaces: remove unused code
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:11:53 +04:00
Andrey Vagin
f995673d99 ipcns: don't use global fdset for dumping namespace
We are going to replace pid on id in names of image files. The id is
uniq for each namespace, so it's more convient, if image files are
opened per namespace.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:11:20 +04:00
Andrey Vagin
b895c73c82 mntns: don't use global fdset for dumping namespace
We are going to replace pid on id in names of image files. The id is
uniq for each namespace, so it's more convient, if image files are
opened per namespace.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:11:09 +04:00
Andrey Vagin
e63f8c20e9 uts: don't use global fdset for dumping namespace
We are going to replace pid on id in names of image files. The id is
uniq for each namespace, so it's more convient, if image files are
opened per namespace.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:10:57 +04:00
Andrey Vagin
faf7b94868 netns: don't use global fdset for dumping namespace
We are going to replace pid on id in names of image files. The id is
uniq for each namespace, so it's more convient, if image files are
opened per namespace.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:10:45 +04:00
Andrey Vagin
762d932cbb namespace: open images per namespace to show them
It's preparation to replace pid on id in image names.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:10:13 +04:00
Andrey Vagin
b1b02fe676 images: split namespace contants per subsystems
Currently all values of constants should be continuous,
because cr_fdset_open is used for opening images for all namespaces.

The next patches will rework this code and image files will be opened
per namespace, then all these ugly settings of one constant to another
will be removed.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:10:07 +04:00
Andrey Vagin
8a23c3106d images: export cr_fdset_open
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:09:56 +04:00
Andrey Vagin
d92874697b zdtm: check, that stopped tasks are restored correctly
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 11:22:17 +04:00
Andrey Vagin
79d47a939d crtoools: add support of stopped tasks (v2)
Currently we catch processes on the exit point from sigreturn.
If a task must be restored in the stopped state, we can send SIGSTOP
before detaching from it.

v2: add more descriptive comment about skipping SIGSTOP in ptrace.c
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 11:21:34 +04:00
Pavel Emelyanov
2169020bea dump: Add comment saying why we dump zombies separately from alive tasks
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 11:17:28 +04:00
Andrey Vagin
ca3a23ec9c dump: transfer pstree_item in dump_task_core_all
Currently we take pid and core from it and we are going to take state.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 11:14:44 +04:00
Andrey Vagin
6b31a75a68 parasite: add a comment why we can safly trap task on sigreturn
The kernel notifies about leaving syscall before starting to deliver
signals. If you don't believe me, pls look at arch/x86/kernel/entry_64.S:

int_ret_from_sys_call
        syscall_trace_leave
        do_notify_resume

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-30 18:46:50 +04:00
Ruslan Kuprieiev
3f1aeb2c86 unix: SOCK_SEQPACKET
Everything in the sk-unix.c is ready for seq-packet sockets.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-30 18:44:57 +04:00
Pavel Emelyanov
d135ad3538 mnt: Collect mntns root from criu, in case we don't dump mount namespace
In case criu and dumpee live in the same mount namespace there's no
need in getting ns' root from init task. We can get it from criu and
(!) void the root == "/" check, required for namespace case.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-27 21:20:41 +04:00
Pavel Emelyanov
7576fa2bdf rst: Create posix timers earlier
No failures should occur after sigchld restore.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-27 21:08:02 +04:00
Pavel Emelyanov
aec951ec07 rst: Don't fail if task entries unmap fail
We cannot fail at that late stage, as everything is restored
and running. In the worst case (unmap fails) restored task would
have one extra mapping.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-27 17:04:20 +04:00
Pavel Emelyanov
f1edcb32f5 rst: Introduce fine-grained pgid-restore synchronization
We can restore task's pgid which is not equal to its pid,
only when the respective group leader is alive. To make
restore reliable we wait for all group leaders to restore
using separate restore stage.

It's better to optimize this -- each task has a pointer on
its group leader and waits for one to become such.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-27 04:38:00 +04:00
Pavel Emelyanov
656693503e zdtm: Check that out-of-root file survives
If a task opens a file, then goes chroot, CRIU should still
be able to dump and restore the now-invisible file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 14:15:31 +04:00
Pavel Emelyanov
2c6b61f122 zdtm: Test for chroot
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 13:59:23 +04:00
Pavel Emelyanov
c378f790b8 fs: Restore root
First of all, this should be done strictly after we've stopped accessing
files by their paths, even absolute. This place is right before going
into restorer.

And the second thing is that we want to re-use the open_fd_by_id engine,
since it handles various tricky cases of open-file-by-path. And since
there's no such thing as fchroot(int fd), we emulate it using the
/proc/self/fd/ links.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 13:59:20 +04:00
Pavel Emelyanov
75b1d4a1e3 rst: Open sys.ns_last_pid before diving into restorer
We restore chroot before doing this, so if we might need to
open one, we may have no access to the /proc/... paths.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 13:59:17 +04:00
Pavel Emelyanov
cd19b2fe25 fs: Reshuffle prepare_fs code flow
Make it ready for root dir restore:
* fix comments
* rename variables
* tune error paths

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 13:59:15 +04:00
Pavel Emelyanov
fe3fb8851e tcp: Support CORK and NODELAY options
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 11:43:02 +04:00
Pavel Emelyanov
4b6e1d6dc0 unix: Print sockets IDs in hex when collect skips them
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 11:40:40 +04:00
Pavel Emelyanov
3ebb368299 unix: Print "socket not found" error message on dump
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 11:39:54 +04:00