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

4636 Commits

Author SHA1 Message Date
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
Andrey Vagin
896fae70d3 zdtm: rollback cwd only if a test case is executed in namespaces
$ bash test/zdtm.sh -i 0 '\(ns/static/env00\|static/pty03\|static/mountpoints\)'
...
==================================== ERROR ====================================
Test: zdtm/live/static/mountpoints, Namespace:
Output file: /root/git/1/criu/test/zdtm/live/static/mountpoints.out
------------------------------------------------------------------------------
00:53:03.267: 26935: FAIL: mountpoints.c:139: Can't umount all the filesystems (errno = 16 (Device or resource busy))
------------------------------------- END -------------------------------------
================================= ERROR OVER =================================

Fixes: 0198590c5a44 (zdtm: Factor out starting the test via Makefule)
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-05 16:33:58 +04:00
Cyrill Gorcunov
5cb0c0d233 vdso: Defer handling untill all zones are restored
In worst case we might be tryin to proxify vdso zone
when vvar only is remmaped but vdso itself is not yet
(left and right zones shifting). Thus vdso_proxify
will complain that vdso is not yet mapped refusing
to restore.

Thus wait until everything is re-mapped then call
for proxification helper.

Reported: Mr. Jenkins
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 22:30:26 +04:00
Cyrill Gorcunov
18fe357563 vdso: Implement vDSO proxification of any vvar/vdso order
In latest linux-next the vdso zone is placed _after_ vvar
zone so eventually we need to handle any combination of
the following cases

 - no vvar zone
 - vvar before vdso
 - vvar after vdso

Here we address all them.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 15:35:03 +04:00
Cyrill Gorcunov
6446fd2c1d vdso: Move parking into a separate routine
Since we might have a several vDSO zones lets hide
handling in arch-specific routines.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 15:34:34 +04:00
Cyrill Gorcunov
6906e1a830 vdso: Drop unneeded @vdso_rt_vma_size variable
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 15:34:22 +04:00
Cyrill Gorcunov
b00bdb2dbc vdso: x86 -- Test VMAs order in vdso_proxify
Make sure we really can do inplace remap.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 15:34:01 +04:00
Cyrill Gorcunov
b8d0b9c773 vdso: x86 -- Make sure that vdso symtable is carrying bindled vmas
In linux kernel 3.17 most probably the vvar and vdso zones will
be in reverse order, ie vvar first and vdso later so do extended
test for these VMAs coming in one bundle.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 15:33:49 +04:00
Cyrill Gorcunov
e67ba97ebe cgroup: Use snprintf in move_in_cgroup
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 14:09:31 +04:00
Cyrill Gorcunov
6ea8fb78a3 cgroup: Use snprintf in collect_cgroups
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 14:09:30 +04:00
Cyrill Gorcunov
357aa793d2 cgroup: Simplify add_cgroup
- xfree works well with nil argument no need for additional tests.
 - no need for @ret variable, we either success returning 0 explicitly,
   either fail with explicit -1

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 14:09:25 +04:00
Cyrill Gorcunov
6c7ea7af9c cgroup: prepare_cgroup_dirs -- Add some more debug printouts
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 14:09:23 +04:00
Tycho Andersen
89d3840c9c build: install target depends on libcriu
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 13:59:00 +04:00
Tycho Andersen
acaca5f14a lib: return -ECONNREFUSED as documented
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 13:58:49 +04:00
Tycho Andersen
df6f80f48e .git: add cgroup01 to gitignore
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 13:58:41 +04:00
Tycho Andersen
14cad21eb5 lib: Generate pkgconfig file
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 13:57:18 +04:00
Tycho Andersen
0ef4f01066 lib: Initialize child messages correctly
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-04 13:10:35 +04:00
Salvatore Bonaccorso
f16a08e54b Small spelling fixes in criu.8 manpage
Signed-off-by: Salvatore Bonaccorso <carnil@debian.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 13:09:54 +04:00
Ruslan Kuprieiev
9f8a7ccaad restore: sigreturn_restore: free core _after_ using it
Currently we have this:
	.......
	/* No longer need it */
	core_entry__free_unpacked(core, NULL);

	ret = prepare_itimers(pid, core, task_args);
	if (ret < 0)
		goto err;
	.......

So we're using ptr right after free-ing it.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 13:09:02 +04:00
Andrey Vagin
787e8a1d88 test/mountpoints: clean up
All mounts is marked as private for one call, so we don't need the
variable private, which has been added in "(55fe0939088d) zdtm: don't
destruct an external mount-namespace"

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 13:07:40 +04:00
Pavel Emelyanov
6ca5ac7541 cg: Merge two equal if-s into one
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
2014-07-17 14:13:02 +04:00
Pavel Emelyanov
45d029f04e cg: Keep "/" in cgroup root paths
The ftw trims tail "/" from path argument.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
2014-07-17 14:13:01 +04:00
Pavel Emelyanov
586eb55f35 cg: Trim proper prefix from ftw's path
After the commit that walks /proc/self/fd/N path instead of the temporary
one, the add_cgroup() started trimming first several bytes from the cgroup
path.

Test passed, since all cgroups were left as is after dump, so criu restore
didn't recreate them but got EEXIST on all mkdir-s.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
2014-07-17 14:12:59 +04:00
Andrew Vagin
dda742ec57 cgroup: don't look up existing mount point
A mount point, which is mounted by someone else, may be umounted in
any moment.

For example the test system executes tests concurrently and sometimes
one test looks up a mount point, which has been mounted by another test.

==================================== ERROR ====================================
Test: zdtm/live/static/inotify00, Namespace: 1
Dump log   : /var/lib/jenkins/jobs/CRIU-dump/workspace/test/dump/inotify00/15535/1/dump.log
--------------------------------- grep Error ---------------------------------
(00.021951) Error (cgroup.c:409): cg: failed walking /var/lib/jenkins/jobs/CRIU-dump/workspace/test/dump/signalfd00/15538/1/.criu.cgmounts.UGj28v/ for empty cgroups
(00.021967) Error (cr-dump.c:1601): Dump core (pid: 15535) failed with -1
(00.025509) Error (cr-dump.c:1914): Dumping FAILED.
------------------------------------- END -------------------------------------
================================= ERROR OVER =================================

In the previous patch I suggested to open a mount point, but it brought
other problems. We may open a directory where a cgroup mount has been
umounted and an owner will get EBUSY on attempt to remove this
directory.

Reported-by: Jenkins Criuovich
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-07-16 17:53:09 +04:00
Pavel Emelyanov
97f7d17905 cg: Don't walk cgroup tree when it's not required
We have two bugs actually.

First, the check for 'item == root_item' in dump_task_cgroup fires
twice: first when we rite inventory (item == NULL as argument and
root_item == NULL because we haven't yet collected tasks) and the
2nd time when we dump the root task itself.

The 2nd issue sits in dump_cgroups() -- if root_cgset == criu_cgset
we don't write cgroups information at all (checking that we don't
have them with list_is_singular() inside that if). That said, we
don't need to read the cgroups tree if we're not going to dump it.

This patch fixes both.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
2014-07-16 17:31:56 +04:00
Pavel Emelyanov
9b6c41f2a0 cg: Remove unused cgroup_dir field
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
2014-07-15 17:29:23 +04:00