2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 13:28:27 +00:00

4661 Commits

Author SHA1 Message Date
Pavel Emelyanov
bf0d4c4b2c sig: Block signals once before forking children
We already have a signals setup helper for this.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-08-07 11:05:33 +04:00
Pavel Emelyanov
8c133309a3 sig: Setup CHLD handler in dedicated helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 11:05:19 +04:00
Pavel Emelyanov
e50d0e7c6f sig: Don't reset CHLD handler to old action, DFL it
The whole idea behind this code was to stop receiving CHLD from
restored tasks after resume. The comment about this is done for
scripts is wrong (we call more scripts before this) because
sigchld_handler() knows about scripts:

commit de71bc69170cfeceb24bddd431ad10b8ea607d42
	 exit = (siginfo->si_code == CLD_EXITED);
	 status = siginfo->si_status;
	+
	+       /* skip scripts */
	+       if (!current && root_item->pid.real != pid) {
	+               pid = waitpid(root_item->pid.real, &status, WNOHANG);
	+               if (pid <= 0)
	+                       return;
	+       }

And since CHLD handler makes little sence after exec, it's easier
just to reset one to default action at the end.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-08-07 11:05:11 +04:00
Pavel Emelyanov
adc63c73d5 sig: Instantly drop SA_NOCLDSTOP for swrk_restore
We tune the CHLD handler if we're restoring root task
as sibling. This tuning is better to be done with one
sigaction() call, rather than two. First, it's shorter
and the second -- it will allow us to move the whole
criu signalling setup into one helper.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-08-07 11:04:21 +04:00
Pavel Emelyanov
bc7d6e315d sig: Don't feed pid argument to prepare_sigactions
We don't need pid in any of these calls actually, they are
all legacy from the old days. I plan to move the call to
prepare_sigactions, so remove the pid argument in advance.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-08-07 11:04:08 +04:00
Pavel Emelyanov
d14abcf7c3 sig: Don't request for old act when restoring sigactions
This old info is simply not used at that place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-08-07 11:03:58 +04:00
Cyrill Gorcunov
1a801c6ded zdtm: timerfd requires new kernels to pass
Reported-by: Jenkins
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 10:28:25 +04:00
Andrey Vagin
a48e52b58c proc_parse: check that scanf fill the offset var
CID 1168165 (#2 of 2): Untrusted array index read (TAINTED_SCALAR)
40. tainted_data: Using tainted variable "hoff" as an index into an
array "str"

$ man 3 scanf
n      Nothing  is expected; instead, the number of characters consumed
      thus far from the input is  stored  through  the  next  pointer,
      which  must  be  a  pointer  to  int.  This is not a conversion,
      although it can be suppressed with the *  assignment-suppression
      character.   The  C  standard says: "Execution of a %n directive
      does not increment the assignment count returned at the  comple‐
      tion of execution" but the Corrigendum seems to contradict this.
      Probably it is wise not to make any assumptions on the effect of
      %n conversions on the return value.

So it isn't not enough to check a return code from scanf().

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 10:26:14 +04:00
Andrey Vagin
e601a2ea5d cgroup: trigger BUG if a mtype is unknown
CID 1230179 (#1 of 1): Resource leak (RESOURCE_LEAK)
15. leaked_storage: Variable "ncd" going out of scope leaks the storage
it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 10:26:02 +04:00
Andrey Vagin
9ba0baabd5 mount: fix dereference after null check
CID 1168169 (#1 of 1): Dereference after null check (FORWARD_NULL)
7. var_deref_model: Passing "mi" to function "do_bind_mount(struct
   mount_info *)", which dereferences null "mi->bind"

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 10:25:53 +04:00
Andrey Vagin
1e0e83701f cgroup: fix dereference before null check
Coverity: 1230177 Dereference before null check

There may be a null pointer dereference, or else the comparison against
null is unnecessary.  In parse_task_cgroup: All paths that lead to this
null pointer comparison already dereference the pointer earlier
(CWE-476)

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 10:24:50 +04:00
Christopher Covington
ca94dc9bed vdso: aarch64 -- Merge fixes from x86
This brings the changes made in the following commits to the
aarch64 copy of the code.

commit 7794f67f2055420c6b6c2967edfbe0c39a7cd744
Author: Cyrill Gorcunov <gorcunov@openvz.org>
Date:   Tue Aug 5 13:59:18 2014 +0400

    vdso: x86 -- Fix missing ability to remap vDSO if only one zone present

commit 066add0de44f462e7482571763f303ded0b4762f
Author: Cyrill Gorcunov <gorcunov@openvz.org>
Date:   Tue Aug 5 13:07:00 2014 +0400

    vdso: x86 -- Simplify vdso_proxify

Signed-off-by: Christopher Covington <cov@codeaurora.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 10:23:02 +04:00
Tycho Andersen
2b1021a43b restore: actually fail if clone() fails
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 10:20:59 +04:00
Cyrill Gorcunov
7158448dd6 timerfd: Implement check routine
Reported-by: Jenkins
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 10:18:09 +04:00
Cyrill Gorcunov
ec3515107c timerfd: zdtm -- Add simple testcase
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 19:20:28 +04:00
Cyrill Gorcunov
ecd432fe27 timerfd: Implement c/r procedure
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 19:20:09 +04:00
Cyrill Gorcunov
5c93ba3b7b timerfd: Add protobuf entries into the image
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 19:18:34 +04:00
Cyrill Gorcunov
f2549c2207 timerfd: protobuf -- Add timerfd_entry
Will need it to carry timerfd entries.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 19:18:25 +04:00
Christopher Covington
f22d0d65fc timerfd: arch, arm -- Add sys_timerfd related syscalls
This is required to support checkpoint and restore of timers
that notify via file descriptors on ARM and AArch64.

Signed-off-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 19:18:18 +04:00
Cyrill Gorcunov
c83ce52594 timerfd: arch, x86 -- Add sys_timerfd related syscalls
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 19:17:57 +04:00
Andrey Vagin
3ab1973067 zdtm: check link-remap and ghost files from a few mntns (v2)
v2: change an author field in a test
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 19:14:22 +04:00
Andrey Vagin
4a15f013fb zdtm: Check that files from alien mnt ns are handled (v2)
Check that files opened before switching to new mount namespace
remain in it after restore. Right now this is not so :( Andrey is
fixing the issue.

Christopher, can you check whether the ns_child's call to system()
works in your minimal set-ups (it launches cat and awk). If not,
then I should rewrite this routine in pure C.

The first version was written by Pavel (xemul@).

v2: don't use test_init_ns
    don't call awk and cat

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 19:14:19 +04:00
Andrey Vagin
6903cc967b notify: open files form a correct mount points (v2)
v2: add a comment before mntns_get_root_by_mnt_id(-1);
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 19:14:18 +04:00
Andrey Vagin
339f456af3 link-remap: open link-remap files from correct mountpoints (v3)
Here is a problem with ghost files. Links are created on restore, but
they can't be created on any mount point, because a mount point can be
non-root bind-mount of another one. So we need to find the root mount
and create all links there.

v2: clean up
v3: add optimization for the case when both links on the same mount
point.
v4: don't look up mount points by mnt_id in a second time.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 19:14:16 +04:00
Andrey Vagin
ce5aa74d10 mount: save local mount point paths on restore
On restore we add a temporary root to a mount point path. It's convinient
for restoring mount namespaces, but real paths are used for restoring
link-remap files.

v2: replace the offset field on a char * field

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 19:14:15 +04:00
Andrey Vagin
7db1e6b9b9 mount: don't set m->bind if m is already mounted
The m->bind will be used to get the "lowest" mount. A mount is
called "lowest" in the chain of bind-mounts when its m->bind is
NULL. I.e. -- it's the mount of the root dir of an FS, all the
others are bind-mounted from it.

The propagate_siblings() is called for each new mount and sets
the bind field for others. A part of these other mounts can be
already mounted.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 19:14:14 +04:00
Christopher Covington
cf219f9284 Customize AArch64 VDSO code
This modifies the x86 VDSO code to work on AArch64.

Signed-off-by: Christopher Covington <cov@codeaurora.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 19:00:17 +04:00
Christopher Covington
99e0a0ccae Copy x86 VDSO code to AArch64
While it duplicates hundreds of lines of code, this is the
short term strategy Cyrill and I have agreed to for supporting
VDSOs across multiple architectures [1]. With better
understanding of where things differ per-architecture, or even
improved consolidation in the kernel, we can hopefully move to
a more shared implementation in the future.

1. http://lists.openvz.org/pipermail/criu/2014-August/015218.html

Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 19:00:16 +04:00
Ruslan Kuprieiev
0628118c31 security: skip obtaining additional groups for root, as they don't matter
As it was reported, some systems don't use /etc/passwd.
On such systems getpwuid fails with undefined errno(see getpwuid(3))
not allowing criu to restrict ids with user additional groups.
Luckily, on such systems criu is run as root, so we can
just skip obtaining additional groups, as they don't matter
for root.

Reported-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Tested-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 18:58:44 +04:00
Pavel Emelyanov
5289ea973a mnt: Extend comment about how mntinfo->mountpoint path looks like
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 12:04:22 +04:00
Pavel Emelyanov
9fd793e565 stat: Pass namespace into phys_stat_resolve_dev, not mnt tree
This makes the API simpler.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 10:57:27 +04:00
Pavel Emelyanov
090587e1a1 stat: Pass namespace into phys_stat_dev_match, not mnt tree
This makes the API simpler.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 10:57:25 +04:00
Ruslan Kuprieiev
ef39c4657b test: security
This test creates 2 users to check how secure is using criu with setuid bit set.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 10:20:30 +04:00
Ruslan Kuprieiev
bd1451f771 security: rename check_ids to check_uids and drop crid argument, v3
Currently check_ids is used to check uids only. So lets rename it
and drop crid argument, as we can use cr_uid directly.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 10:20:29 +04:00
Ruslan Kuprieiev
2b268c6c21 security: check additional groups,v5
Currently, we only check if process gids match primary gid of user.
But process and user have additional groups too. So lets:
     1) check that process rgid,egid and sgid are in the user's grouplist.
     2) on restore check that user has all groups from the images.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 10:20:27 +04:00
Cyrill Gorcunov
a1e2da9b56 vdso: restorer -- Don't forget to access proper vma from the list
Otherwise we might take a look on last vma from previous
cycle not running vdso analisys at all.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 09:40:47 +04:00
Cyrill Gorcunov
7794f67f20 vdso: x86 -- Fix missing ability to remap vDSO if only one zone present
Occasionally I ruined the ability to do a in-place remap for
pre 3.16 kernels. Bring it back.

CID 1230182:  Logically dead code  (DEADCODE)

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 09:40:39 +04:00
Cyrill Gorcunov
066add0de4 vdso: x86 -- Simplify vdso_proxify
No need for second if() statement, merge everything
in previous one.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 09:38:53 +04:00
Pavel Emelyanov
914ab7f245 util: Don't xfree pointer on xmalloc-ed pointer
... free the pointer itself :)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 09:37:40 +04:00
Pavel Emelyanov
590765164c files: Don't double-close the image fd on error
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 09:37:32 +04:00
Pavel Emelyanov
394096b17c files-reg: Sanitize rlb and rlb->path malloc/rollback code flow
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 09:37:27 +04:00
Pavel Emelyanov
5552f9e727 files-reg: Don't dereference pointer before its NULL check
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 09:37:21 +04:00
Pavel Emelyanov
57965aabaa rst: Check for task->state to restore in one place
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 09:37:14 +04:00
Ruslan Kuprieiev
1211ca01ef make: clean at test/rpc when performing "make clean" from main dir
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 09:36:37 +04:00
Ruslan Kuprieiev
c3078e79ec make: test: rpc: don't forget to delete rpc_pb2.pyc
When performing "make clean" rpc_pb2.pyc should be deleted as well.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 09:36:00 +04:00
Andrey Vagin
b8c93feb1e file: use ralative path for retoring files
openat() is used to open files, so absolute pathes can't be used

v2: change the comment
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-05 16:40:17 +04:00
Andrey Vagin
85b3d86e5b ghost: create ghost devices and directories in a specified ns
Here is a bug now. A path for devices and directories should be
generated with a specified root.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-05 16:38:40 +04:00
Andrey Vagin
967dba606a mount: add helper mntns_get_root_by_mnt_id
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-05 16:38:19 +04:00
Andrey Vagin
e4e22a00f7 mount: save remapped links on tmpfs (v2)
For that mnt namespaces should be dumped after files.

v2: rework enumeration of namespaces in dump_mnt_namespaces()
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-05 16:35:41 +04:00
Andrey Vagin
8d446a7af4 mount: execute collect shared for all mounts
Currently collect_shared is executed for each mount namespace separately,
so we miss the dependencies between namespaces.

For example, we have two namespaces, the first one contains a tmpfs mount
and the second one contains a non-root bind-mount of this tmpfs. Without
this patch this example can't be dumped.

On restore mnt_build_tree() is called for all namespaces at once, thus
this bug doesn't exist there.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-05 16:35:17 +04:00