Commit graph

5271 commits

Author SHA1 Message Date
Kir Kolyshkin
3ea2fd78eb crtools.c: fix compilation by clang
Fix the following error:

> >   LINK     arch/x86/syscalls.built-in.o
> > arch/x86/crtools.c:36:20: error: unused function '__check_code_syscall'
> >       [-Werror,-Wunused-function]
> > static inline void __check_code_syscall(void)

As the function consists of a few BUILD_BUG_ONs, it gets optimized out.
Let's add __attribute__((__unused__)) so clang stops complaining.

[v2: s/used/unused/, fix all the arches, whitespace cleanup]

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-05-05 13:44:34 +03:00
Kir Kolyshkin
43fb948400 Makefile: allow optional local rules
I use Makefile.local to add my own rules for submitting a build
to Coverity. As those rules contain login credentials, they should
be kept private. Including Makefile.local (if present) seems to be
the best way to achieve that.

Also, add Makefile.local to .gitignore to make sure it never gets
commited into repo.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-05-05 13:43:55 +03:00
Andrey Vagin
af555618c6 image: don't free an img object from pb_write_one()
This is unexpected behaviour.
pb_write_one
  open_image_lazy
    do_open_image
      xfree(img)

255             if (pb_write_one(img, &cpu_info, PB_CPUINFO) < 0) {
>>> >>>     CID 92728:  Memory - illegal accesses  (USE_AFTER_FREE)
>>> >>>     Calling "close_image" dereferences freed pointer "img".
256                     close_image(img);
257                     return -1;
258             }

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-05-05 13:41:10 +03:00
Andrey Vagin
281a0f9d20 kerndat: pass null-terminated string into strstr
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-05-05 13:39:43 +03:00
Andrey Vagin
59bb688033 kerdat: don't leak a file descriptor
288             if (flock(fd, LOCK_SH)) {
289                     pr_perror("Can't take a lock\n");
>>> >>>     CID 92726:  Resource leaks  (RESOURCE_LEAK)
>>> >>>     Handle variable "fd" going out of scope leaks the handle.
290                     return -1;
291             }

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-05-05 13:39:19 +03:00
Kir Kolyshkin
8ac865f3ee Fix check for open_image() ret
When open_image() was modified to return a pointer rather than an int
in commit 295090c1, these two checks were overlooked and never fixed.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Andrew Vagin <avagin@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-05-05 13:37:16 +03:00
Kir Kolyshkin
b17962ad8d Fix pr_perror() usage
When using pr_perror(), format string should not end with \n,
as it is added by the macro itself.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Andrew Vagin <avagin@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-05-05 13:36:29 +03:00
Laurent Dufour
de9df91002 Per architecture restorer trampolines
Some architectures like ppc64 requires a trampoline to be called prior to
the standard restorer services.

This patch introduces 3 trampolines which can be overwritten by
architectures in arch/x/include/asm/restore.h:
 - arch_export_restore_thread
 - arch_export_restore_task
 - arch_export_unmap

The architecture which doesn't need to overwrite them, has nothing to do.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-05-05 13:35:48 +03:00
Laurent Dufour
303b875892 arch/ppc64: Add PowerPC 64 LE support
This patch initiates the ppc64le architecture support in CRIU.

Note that ppc64 (Big Endian) architecture is not yet supported since there
are still several issues to address with this architecture. However, in the
long term, the two architectures should be addressed using the almost the
same code, so sharing the ppc64 directory.

Major ppc64 issues:

Loader is not involved when the parasite code is loaded. So no relocation
is done for the parasite code. As a consequence r2 must be set manually
when entering the parasite code, and GOT is not filled.

Furthermore, the r2 fixup code at the services's global address which has
not been fixed by the loader should not be run. Branching at local address,
as the assembly code does is jumping over it.

On the long term, relocation should be done when loading the parasite code.

We are introducing 2 trampolines for the 2 entry points of the restorer
blob.  These entry points are dealing with r2. These ppc64 specific entry
points are overwritting the standard one in sigreturn_restore() from
cr-restore.c.  Instead of using #ifdef, we may introduce a per arch wrapper
here.

CRIU needs 2 kernel patches to be run powerpc which are not yet upstream:
 - Tracking the vDSO remapping
 - Enabling the kcmp system call on powerpc

Feature not yet supported:
- Altivec registers C/R
- VSX registers C/R
- TM support
- all lot of things I missed..

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-30 09:57:49 +03:00
Andrew Vagin
641693f8f0 proc_parse: remove a debug message
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-29 17:24:01 +03:00
Andrew Vagin
84c65f00f9 proc_parse: handle errors for breadline()
00:03:27.746 (00.008815) Error (bfd.c:149): bfd: Error reading file: No such process

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-29 17:23:55 +03:00
Andrew Vagin
a2a0e2f2ed test/rpc: don't use shell-job
We want to execute this test in Jenkins.

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-27 17:51:41 +03:00
Andrew Vagin
fe0afaa787 test/rpc: unlink pidfile at the end
It's required to execute the test a few times

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-27 17:51:34 +03:00
Andrew Vagin
bc3ee6c50d jenkins: use tmpfs for images in criu-iter
It resuces I/O load.

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-27 17:51:30 +03:00
Andrey Vagin
4834c39d45 jenkins/criu-iter: reduce a number of jobs
maps007 fails due to intensive load

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-27 15:05:45 +03:00
Andrey Vagin
3785d112c5 test/unix-callback: don't use the --shell-job optios
It isn't required here and Mr Jenkins can't execute this job.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-27 15:03:23 +03:00
Andrey Vagin
76df748c6c jenkins: use tmpfs for images in criu-sibling
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-27 15:03:22 +03:00
Oleg Nesterov
92480346e1 add RPC options for for --enable-fs and --skip_mount
Subject.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-27 14:57:27 +03:00
Oleg Nesterov
be4acd9d6e fix parse_mnt_flags() to dump/restore STRICTATIME correctly
CRIU always retores the mounts as MNT_RELATIME. This is because the
kernel uses this mode by default, so we need to pass MS_STRICTATIME
explicitely if we didn't see "noatime" or "MS_RELATIME".

While at it, make mnt_opt2flag[] and sb_opt2flag "static", otherwise
gcc actually creates these arrays on stack even if there are "const".

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-27 14:54:44 +03:00
Andrey Vagin
25267e5b30 lock: parse the lock field in fdinfo if it's avaliable (v2)
/proc/locks can contain a wrong pid for a lock and we always need to
check this fact.  Starting with the 4.1 kernel, locks are reported
in fdinfo.

v2: rebase to the curret master
    skip note_file_lock()

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-27 14:53:24 +03:00
Andrey Vagin
b9c14a09b0 kerndat: check the lock field in fdinfo (v2)
Starting with the 4.1 kernel, fdinfo contains information about file
locks.

v2: s/has_lock/has_fdinfo_lock/
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-27 14:53:22 +03:00
Andrew Vagin
a049768242 test: Fix random jenkins-other tests failures
- ext pipe test should build binar
- criu no longer accepts "extra" empty arguments
- adduser doesn't add more than one same user

All this came unnoticed due to error in tests failure detection
(36a13cbd test: don't ignore errors other other tests)

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-24 19:21:09 +03:00
Pavel Emelyanov
80d913dc41 test: Run unix-ext test with more debugging
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-24 19:19:20 +03:00
Andrey Vagin
36a13cbd5a test: don't ignore errors other other tests
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-24 15:57:18 +03:00
Cyrill Gorcunov
3d377863bf make: Introduce ldflags-y variable
We need a custom flags to build 32bit varian of criu
on 64bit host system, lets pass @ldflags-y here for
that.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-24 14:52:55 +03:00
Cyrill Gorcunov
b82a441525 x86: Add explicit type conversion for encode/decode pointer
Eliminate warning on 32bit builds.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-24 14:52:55 +03:00
Cyrill Gorcunov
05b28b7ba1 x86: Add explicit type conversion in show_rt_xsave_frame
So won't be a warning on x86-32 (I don't like PRI conversion,
it's ugly as hell, plain long is enough here).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-24 14:52:55 +03:00
Cyrill Gorcunov
1647e056d0 make: Itroduce PROTOUFIX variable
We will need it for x86-32 as well, not on ARM only.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-24 14:52:55 +03:00
Cyrill Gorcunov
9fd61881d9 make: Export @ARCH and @SRCARCH
We will need them for x86-32.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-24 14:52:55 +03:00
Cyrill Gorcunov
89671a0929 x86: x86-64 syscalls -- Rework build procedure
- Get rid of shell script, we can do everything via make itself in parallel mode
 - Collect syscall related data into syscalls subdirectory (we gonna implement
   32 bit mode soon)
 - We can't drop off __NR_ constants because we're using them in parasite code
   (when we inject dumper and for "criu exec" mode)

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-24 14:52:55 +03:00
Oleg Nesterov
497b79d4ba simplify the asprintf() failure handling in add_fsname_auto()
Contrary to what I naively thought, the contents of fsauto_names
is undefined if asprintf(&fsauto_names) and this was fixed by
a052e0b60a "check return code of asprintf".

But we can simplify this code a bit. If we rely on return value from
asprintf(), we can simply nullify fsauto_names on failure and avoid
the assymetrical "return false".

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-24 14:33:55 +03:00
Andrey Vagin
161cb0b1eb zdtm: add a test with a dead thread leader and alive threads
This case is not supported now
[root@avagin-fc19-cr criu]# bash test/zdtm.sh -r static/pthread02
Execute static/pthread02
./pthread02 --pidfile=pthread02.pid --outfile=pthread02.out
Dump 3186
WARNING: pthread02 returned 1 and left running for debug needs
Test: zdtm/live/static/pthread02, Result: FAIL
==================================== ERROR ====================================
Test: zdtm/live/static/pthread02, Namespace:
Dump log   : /root/git/locks/criu/test/dump/static/pthread02/3186/1/dump.log
--------------------------------- grep Error ---------------------------------
(00.033195) Error (cr-dump.c:886): Zombies with threads are not supported
(00.033256) Error (cr-dump.c:1943): Dumping FAILED.
------------------------------------- END -------------------------------------
================================= ERROR OVER =================================

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-24 14:31:55 +03:00
Andrey Vagin
e7c05c5eba ptrace: print PID in error messages
We want to know which process can not be handled.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-24 14:31:21 +03:00
Andrey Vagin
cb9b6de396 zdtm: add ability to execute restore with the restore_sibling option
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-24 14:30:48 +03:00
Andrey Vagin
b840ce4ac7 restore: attach to threads of the root task in case of rst_sibling
In case of rst_sibling, we are tracing the root task, but we are tracing
only the leader thread, so we must attach to other threads to stop them.

Reported-by: Ross Boucher <rboucher@gmail.com>
Cc: Ross Boucher <rboucher@gmail.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Tested-by:  Ross Boucher <rboucher@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-23 19:51:50 +03:00
Christopher Covington
cefe22bdac Use run-time page size where it matters
In AArch64, pages may be 4K or 64K depending on kernel configuration.
The GNU C Library documentation suggests [1], "the correct interface
to query about the page size is sysconf". Introduce one new
architecture-specific function-like macro, page_size(), that on x86
and AArch32 remains a constant so as to minimally affect performance,
but on AArch64 is sysconf(_SC_PAGESIZE) for correctness.

1. https://www.gnu.org/software/libc/manual/html_node/Query-Memory-Parameters.html

To minimize churn, the PAGE_SIZE macro is left as a build-time
estimation of what the run-time page size might be.

This fixes the following errors for CRIU on AArch64 kernels with
CONFIG_ARM64_64K_PAGES=y, allowing dump of
`setsid sleep < /dev/null &> /dev/null` to succeed.

Error (kerndat.c:48): Can't stat self map_files: No such file or directory

Error (util.c:668): Can't read pme for pid 90: No such file or directory

Error (parasite-syscall.c:1135): Can't open 89/map_files/0x3ffb7da0000-0x3ffb7dac000 on procfs: No such file or directory

Signed-off-by: Christopher Covington <cov@codeaurora.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-22 15:39:05 +03:00
Andrey Vagin
208fe10565 cgroup: don't play with a function exit code
We should not have a chance to exit with a wrong code on error
paths.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-22 15:37:13 +03:00
Andrey Vagin
a67e9f7bb9 vdso: don't play with a function exit code
We should not have a chance to exit with a wrong code on error
paths.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-22 15:36:49 +03:00
Andrey Vagin
e59a81bab6 proc_parse: handle a return code of fopen_proc
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-22 15:36:20 +03:00
Andrey Vagin
4a36feacc7 parse_proc: take into account that breadline can return an error code
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-22 15:36:12 +03:00
Andrey Vagin
6b4ecb90db proc_parse: don't play with a function exit code
We should not have a chance to exit with a wrong code on error
paths.

|^^^\
|    \________________
| **                |_\
\_______/^^^^^^^/_____/
       /      /
      /     /
     /____/

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-22 15:34:37 +03:00
Oleg Nesterov
e448934a19 report fd/path if dump_one_reg_file()->lookup_nsid_by_mnt_id() fails
"Unable to look up the %d mount" doesn't really help to understand
the problem, add a bit more info.

And perhaps it makes more sense to change dump_task_files_seized()
to report fd/path if dump_one_file() fails.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-22 15:30:06 +03:00
Oleg Nesterov
80c92e90c2 report the potential selinux problem if mmap_seized() fails
selinux can deny mmap(PROT_WRITE | PROT_EXEC) and in this case it is
not clear why CRIU fails, "Can't allocate memory for parasite blob"
doesn't tell too much. Add a pr_warn() hint for the user.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Cyrill Gorcunov<gorcunov@openvz.org>
Acked-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-22 13:29:01 +03:00
Tycho Andersen
d885caf941 add RPC options for automatic external mount handling
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-22 12:29:47 +03:00
Tycho Andersen
a052e0b60a check return code of asprintf
On ubuntu (gcc 4.9.2), I get:

mount.c: In function ‘add_fsname_auto’:
mount.c:1414:3: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result]
   asprintf(&fsauto_names, "%s,%s", old, names);
   ^
cc1: all warnings being treated as errors

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-22 12:29:17 +03:00
Andrey Vagin
2702615286 show: read a second magic when it's required
Now image files contains two magics, so we need to handle both of them.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-21 16:15:44 +03:00
Tycho Andersen
90e79b741c mnt: remember to restore MS_UNBINDABLE
Note that if the root is unbindable then restore will fail because
cr_pivot_root() tries to bind mount the put dir. If this is a case we want to
support, we may want to rearrange how this code is called.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-21 16:14:21 +03:00
Tycho Andersen
30ecf44f48 mnt: do_new_mount should restore sharing
The function masks off sharing in the initial setting, but doesn't correctly
reset the flags afterwards.

CC: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Andrew Vagin <avagin@odin.com>
Looks-good-to: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-21 16:14:20 +03:00
Oleg Nesterov
7e93eb3bec make it possible to use --enable-fs more than once
Change add_fsname_auto() to join multiple --enable-fs options.

Note: "all" always wins, and "--enable-fs foo,all,bar" results
in fsauto_names = "all" too.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-21 16:12:14 +03:00
Oleg Nesterov
03cb8a0a66 fix the wrong usage of strtok() in fsname_is_auto()
I am stupid. fsname_is_auto() can't use strtok(), the 2nd call will
see zeroes instead of commas in fsauto_names.

Add the css_contains() helper and change fsname_is_auto() to use it.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-21 16:12:13 +03:00