Previously, the GOT table was using the same memory location as the
args region, leading to difficult to debug memory corruption bugs.
We allocate the GOT table between the parasite blob and the args region.
The reason this is a good placement is:
1) Putting it after the args region is possible but a bit combersome as
the args region has a variable size
2) The cr-restore.c code maps the parasite code without the args region,
as it does not do RPC.
Another option is to rely on the linker to generate a GOT section, but I
failed to do so despite my best attempts.
Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
We don't need to push 0 on the stack. This seems to be a remnant of the
initial commit of 2011 that had a `pushq $0`.
The 16 bytes %rsp alignment was added with commit 2a0cea29 in 2012.
This is no longer necessary as we already guarantee that %rsp is 16
bytes aligned. A BUG_ON() is added to enforce this guarantee.
Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
Previously, __export_parasite_cmd was located in parasite-head.S, and
__export_parasite_args located exactly at the end of the parasite blob.
This is not ideal for various reasons:
1) These two variables work together. It would be preferrable to have
them in the same location
2) This prevent us from allocating another section betweeen the parasite
blob and the args area. We'll need this to allocate a GOT table
This commit changes the allocation of these symbols from assembly/linker
script to a C file.
Moreover, the assembly entry points that invoke parasite_service()
prepares arguments with hand crafted assembly. This is unecessary.
This commit rewrite this logic with regular C code.
Note: if it wasn't for the x86 compat mode, we could remove all
parasite-head.S files and directly jump to parasite_service() via
ptrace. An int3 architecture specific equivalent could be called at the
end of parasite_service() with an inline asm statement.
Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
It is unnecessary and potentially confusing for understanding the memory
layout requirement of the parasite blob.
Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
It removes the potential confusion when it comes to virtual address vs
offsets. Further, doing so makes naming more consistent with the rest of
the parasite_blob_desc struct.
Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
compel_relocs_apply() was taking arguments mostly from the struct
parasite_blob_desc. Instead of passing all the arguments, we pass a
pointer to the struct itself.
This makes the code safer, as cr-restore.c calls compel_relocs_apply().
It previously needed to poke into what can be considered private
variables of the restorer-pie.h file.
To allow the parasite_blob_desc struct to be populated without a
parasite_ctl struct, we expand the compel API to export a
parasite_setup_c_header_desc() in the generated pie.h.
Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
COMMON symbols are emitted for global variable that are not initialized
in shared libraries.
They typically end up in the .bss section when linking an executable.
Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
This change is very straightforward. We don't skip the cgroup2
controller and dump it as any other controllers.
Signed-off-by: Andrei Vagin <avagin@gmail.com>
I pushed the wrong branch to the pidns PR
https://github.com/checkpoint-restore/criu/pull/1056
which resulted in the wrong patches getting merged.
This is the actual result from the review.
Signed-off-by: Adrian Reber <areber@redhat.com>
file_validation_method field added to cr_options structure in
"criu/include/cr_options.h" along with the constants:
FILE_VALIDATION_FILE_SIZE
FILE_VALIDATION_BUILD_ID
FILE_VALIDATION_DEFAULT (Equal to FILE_VALIDATION_BUILD_ID)
Usage and description information is yet to be added
Usage:
--file-validation="filesize" (To use only the file size check)
--file-validation="buildid" (To try and use only the build-id check)
Signed-off-by: Ajay Bharadwaj <ajayrbharadwaj@gmail.com>
efi.h: Required for accessing the build-id of .efi files
This adds functions to find, store and compare with the stored build-id.
get_build_id() calls 32-bit or 64-bit helper functions depending on
the bitness of the ELF file after first ensuring that it is actually
an ELF file by checking for the magic number.
The number of iterations while searching the elf file for the
build-id before giving up (500 while searching the note section)
are limited.
Signed-off-by: Ajay Bharadwaj <ajayrbharadwaj@gmail.com>
This adds build-id, checksum, checksum-config and checksum-parameter fields
to RegFileEntry to store metadata used for file verification.
build_id: Holds the build-id if it could be obtained
checksum: Holds the checksum if it could be obtained
checksum_config: Holds the configuration of bytes for which checksum has
been calculated (The entire file, first N bytes or every Nth byte)
checksum_parameter: Specifies the value of 'N', if required, for the
configuration of bytes
Signed-off-by: Ajay Bharadwaj <ajayrbharadwaj@gmail.com>
When groups already have desired values, we skip calling setgroups.
Furthermore, this check allows us to restore when in an
unprivileged user namespace that cannot use setgroups.
Signed-off-by: Angie Ni <avtni@google.com>
Now that the new CRIU to criu-image-streamer protocol is in, we can use
the master branch of criu-image-streamer.
Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
CRIU sometimes returns 1 from main() with no explanation.
Changes made add more logging in the case of
initialization errors in config and crtools.
Signed-off-by: Angie Ni <avtni@google.com>
CRIU sometimes returns 1 from main() with no explanation.
These changes add additional logging for initialization errors in kerndat.
Signed-off-by: Angie Ni <avtni@google.com>
Adapt netns_ext tests to also work with pid namespaces and move it from
test/others/netns_ext/ to test/others/ns_ext/.
Also enable ns_ext tests in Travis runs.
Signed-off-by: Adrian Reber <areber@redhat.com>
This allows CRIU to restore a process into an existing PID namespace.
During checkpointing the PID namespace can be marked as external using:
--external pid[<inode>]:<label>
This can be the host PID namespace or any other PID namespace.
During restore a process can be restored into an existing PID namespace
using:
--inherit-fd fd[<FD>]:<label>
The <label> has to be the same for checkpoint and restore. CRIU uses
the <label> to know which resource the user means.
A process can start in the host PID namespace and can be moved to
another namespace or the other way around. Any PID namespace can be
used.
This is necessary to checkpoint containers in a POD which share certain
namespaces and this code to support external PID namespaces is the first
step towards checkpointing and restoring containers which belong to a
POD.
This is not using the --join-ns functionality as it is not possible to
move existing process to a PID namespace using setns(). Only child
process will be created in the PID namespace and that is why setns()
needs to be called before clone().
Signed-off-by: Adrian Reber <areber@redhat.com>
This loads and stores the key for an external PID namespace if specified
by the user using: --external pid[<inode>]:<label>
Preparation for restoring into existing PID namespaces.
Signed-off-by: Adrian Reber <areber@redhat.com>
Create a session leader and it's child - session member, make leader
zombie. To restore this criu will need to create a helper task a child
of our zombie so that member can inherit session. Before fixes in this
patchset we segfault on empty ids and fail to restore cgroups because of
empty cg_set
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
In case if our parent is a dead task (zombie) or a helper which in it's
turn has zombie parent, and parent thus has zero cg_set we should look
for current cgset deeper.
Fixes: #1066
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
In case if our parent is a dead task (zombie) we should lookup
for parent ids which will be inherited on restore. Otherwise
parent->ids may be nil and SIGSEGV produced.
Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Rework and port from vzcriu:
87b320964 ("vz7: mount: restore_task_mnt_ns - Lookup for mount namespace
conditionally")
Fixes: #1066
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
When uffd_open is called from kerndat_uffd, userfaultfd failure is not
considered an error, so the goal is to suppress the error message --
instead, we print this message as info.
If the function fails, it is the responsibility of the caller
to print the error message.
Signed-off-by: Angie Ni <avtni@google.com>
* Mark lowcase criu as code in the environment section
* Add missing brace around the reference to https://criu.org/Secrity
* Fixup an admolition block that GitHub cannot render
* Spelling fixups
* s/github/GitHub/g
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Import "How to submit patches" article from CRIU wiki and update its
format to match GitHub markdown.
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
The layout of xsave frame in a standart format is predefined by the hardware.
Lets make sure we're increasing in frame offsets and use latest offset where
appropriate.
https://github.com/checkpoint-restore/criu/issues/1042
Reported-by: Ashutosh Mehra <mehra.ashutosh@ibm.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
TL;DR: this makes possible -v with criu swrk, and removes showing usage
which is useless in swrk mode.
1. Since criu swrk command is not described in usage, there is no sense
in showing it. Instead, show a one-line hint about how to use it.
2. In case some global options (like -v) are used, argv[1] might not
point to "swrk". Use optind to point to a correct non-option
argument.
3. While at it, also error out in case we have extra arguments.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This adds the minimal configuration to run Fedora 31 based VMs on
Travis.
This can be used to test cgroupv2 based tests, tests with vdso=off and
probably much more which requires booting a newer kernel.
As an example this builds CRIU on Fedora 31 and reconfigures it to boot
without VDSO support and runs one single test.
Signed-off-by: Adrian Reber <areber@redhat.com>
Without clone3() CRIU was able to detect a process with a wrong PID only
in the already created child process. With clone3() this error can
happen before the process is created.
In the case of EEXIST this error will now be correctly forwarded to an
RPC client.
This was detected by running test/others/libcriu on a clone3() system.
Signed-off-by: Adrian Reber <areber@redhat.com>
Although the CRIU version is exported in macros in version.h it only
contains the CRIU version of libcriu during build time.
As it is possible that CRIU is upgraded since the last time something
was built against libcriu, this adds functions to query the actual CRIU
binary about its version.
Signed-off-by: Adrian Reber <areber@redhat.com>
When we use swrk, we have a mechanism to send notifications over RPC.
It is cleaner and more straightforward than sending \0 to status fd.
For now, both mechanisms are supported, although status fd request
option is now deprecated, so a warning is logged in case it's used.
Guess we can remove it in a few years.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
The name close_service_fd() is misleading, as it not just closes the
status_fd, but also writes to it. On a high level, though, it signals
the other side that we are ready, so rename to status_ready.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
7. criu-3.14/criu/timens.c:67: leaked_storage: Variable "img" going out of scope leaks the storage it points to.
65| if (id == 0 && empty_image(img)) {
66| pr_warn("Clocks values have not been dumped\n");
67|-> return 0;
68| }
Signed-off-by: Adrian Reber <areber@redhat.com>