In case of error inside collect_cgroups we need
- @ctls list has been spliced into @cs->ctls so we cant just free it,
but rather use put_ctls on @cs->ctls
- delete @cs->l from global @cg_sets list before free it
Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Reviewed-by: Andrew Vagin <avagin@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
If add_cgroup_properties failed we have @ncd sitting
in @match->children or @current_controller->heads
list, and then we free @ncd entry leaving those
lists carrying dead pointers.
Add proper rollback action.
Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Since we're freeing list entries don't forget to
initialize list then, otherwise it gets out with
free entries and may hit use-after-free bug.
Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
We will still able to distinguish if it's garbage in ax register, but
this is definitely prettier:
(00.036900) 687 was trapped
(00.036903) 687 is going to execute the syscall 158
(00.036928) 687 was trapped
(00.036931) 687 is going to execute the syscall 173
Than that:
(00.024403) 687 was trapped
(00.024407) 687 is going to execute the syscall 9e
(00.024419) 687 was trapped
(00.024421) 687 is going to execute the syscall ad
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Previously when we've been on early stage we
tried to workaround lack of prlimit libc call
simply providing own implementation, but it
cause problems on some libc configurations so
simply use rlimit64 and __NR_prlimit64 syscall
directly.
The kernel must support __NR_prlimit64 syscall
and provide rlimit64 structure as well.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
The option was in use when we didn't have the /proc/pid/ns links
and thus ns ids. Later we used it at restore time to tell which
namespaces to restore the pstree into. Right now ids are always
generated and this option has no effect (and meaning).
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
We've been writing this file since 0.4, hopefully nobody's
using such an oldie :)
v2: Don't BUG_ON, but return error, as this can be triggered
by corrupting images.
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This helper is used in both PIE and non-PIE code.
For the second we can use normal pr_perror.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Since AIO ring is never pre-dumped, it never has a parent
in pre-dump. Make generate_iovs() to know this.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Description:
1)Create io context, submit several io operations and
get events of some of them.
2)Sleep on signal.
3)Check tail, head and nr events restored correct.
4)Emit one more io operation.
5)Check tail has moved one number forward (i.e. synchronize
in-kernel and userspace tails if they were different).
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Check nr in aio header during dump and correctness of
tail, head and nr during restore.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
1)Dump/restore mmaped aio ring like any other private vma entry,
with the only exception we do not predump it.
2)Create io context, set head and tail using write to /dev/null.
3)Copy aio ring restored in (1) to created in (2).
4)Remap (2) to address of (1).
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Move the declaration from .c to header file.
Also rename parasite_check_aios() since we
have one more function with the same name.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
The page server already knows how to create a TCP server and client. The
code has been hidden behind static-s in page-xfer.c. This commit moves
the common TCP server/client code to util.c to be able to also use it
in the upcoming remote lazy-server/lazy-client userfaultfd enhanced criu.
Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Add checks that structure end is inside memory area [mem, mem + size]
before dereferencing structures.
Otherwise, for example, vdso_fill_symtable will try to dereference
ehdr members even with vma size 0.
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
As I am here to fix some things, I would like to remove UB-based
pointer compare (6.5.8.5). We have -fno-strict-aliasing in pie
CFLAGS, but it even looks nicer and more readable with uintptr_t.
Impact: refactoring
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Add Elf32 types and wrap them with Elf64 into some more generic types.
This is for parsing vDSO from image file.
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Parasite should cleanup after fauilure and remove read-protection
from VMAs. Check it with maps00 test & fault injection.
Tested on travis with some addition:
python test/zdtm.py run -t zdtm/static/maps00 --fault 3 --keep-going --report report -f h || false
https://travis-ci.org/0x7f454c46/criu/jobs/119252291
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
By default criu tries to create parasite mem with memfd syscall,
which is present in many systems. Let's check also the legacy way.
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
With autofs patches we've merged a small engine that allows
to queue random routine for post-prepare execution. Re-use
this for unix sockets' interconneting routine.
Also this is a tiny optimization -- when we don't have unix
sockets to interconnect we don't make extra list walk.
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Consider when there is a double fork of helpers or zombies, e.g. when a
zombie has a session id which doesn't match its pid. If the child dies and
exits before the grandchild, the grandchild reparents to init, and when the
task dies init doesn't have it in the helper list, so init dies as well,
viz. the log below.
(00.118789) Add a helper 293 for restoring SID 293
(00.118792) Attach 294 to the temporary task 293
...
(01.394403) 294: Restoring zombie with 0 code
...
pie: Task 294 exited, status= 0
(01.434279) Error (cr-restore.c:1308): 12097 killed by signal 19
(01.434420) Error (cr-restore.c:1308): 12097 killed by signal 19
(01.450258) Switching to new ns to clean ghosts
(01.450324) Error (cr-restore.c:2138): Restoring FAILED.
Let's have the helpers reap their children before they exit to avoid this.
v2: block SIGCHLD when waiting on helpers so that it doesn't race with the
SICGHLD handler
v3: * only helpers should collect their children, zombies can't have kids
* don't double decrement nr_tasks in zombie case
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
The following error happens when building CRIU on Fedora 22:
CC autofs.o
autofs.c: In function ‘autofs_mount’:
autofs.c:892:9: error: implicit declaration of function ‘add_post_prepare_cb’ [-Werror=implicit-function-declaration]
ret = add_post_prepare_cb(autofs_add_mount_info, mi);
^
cc1: all warnings being treated as errors
Adding forward declaration of add_post_prepare_cb resolves the issue.
Signed-off-by: Mike Rapoport <rapoport@il.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Autofs restore needs to create some shared data structures to be able to pass
data to actual autofs master.
But on mount restore stage shared data is not configured yet.
This list of objects and their actors is processed after all mounts and shared
data are restored to let autofs to create the objects.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Before the nsroot= mount option, we were just getting lucky because the
cgroup superblocks "matched" when inspecting them from userspace, so we
were actually getting a bind mount from the host when migrating from within
cgroup namespaces.
Instead, let's actually do a new (i.e. not a bind mount) for cgroup
namespaces. For this, we need two things:
1. to prepare the cgroup namespace (and thus the cgroups) before the mount
ns, so when the mount() occurrs it is relative to the right cgroup path.
2. not reject cgroup filesystems with no root. A cgroup ns mount looks
like:
223 222 0:22 /lxc/unpriv /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd,nsroot=/lxc/unpriv
i.e. it has /lxc/unpriv as its root, and thus doesn't look rooted to CRIU.
We use the fstype->parse hook to rewrite this root to /, since it
is handled by the cgroup ns infrastructure.
v2: add new fstype->munge hook, allowing fstypes to munge their parsed
mountinfo entries if they want to. this allows us to get rid of the
ugly hacks with FSTYPE__CGROUP everywhere in teh patch.
v3: s/fstype->munge/fstype->parse for FSTYPE__CGROUP
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
The target has been broken for some time without complaints from users.
https://lists.openvz.org/pipermail/criu/2016-March/026525.html
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>