2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 22:35:33 +00:00
Commit Graph

9420 Commits

Author SHA1 Message Date
Andrey Vagin
6d785e6cdd unix: resolve a socket file when a socket descriptor is available
unix_process_name() are called when sockets are being collected,
but at this moment we don't have socket descriptors.

A socket descriptor is reuired to get mnt_id, what will allow to resolve
a socket path in its mount namespace.

Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-12 11:45:30 +03:00
Andrey Vagin
0286752b45 kerndat: check the SIOCUNIXFILE ioctl for unix sockets
This ioctl opens a file to which a socket is bound and
returns a file descriptor. This file descriptor can be used to get
mnt_id and a file path.

Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-12 11:45:30 +03:00
Andrey Vagin
8ebf1c48f8 unix: handle sockets with USK_CALLBACK as external sockets
The USK_CALLBACK flag means that a socket is externel and will be
restored by a plugin. open_unixsk_standalone should not be called to
these sockets.

$ make -C test/others/unix-callback/ run
...
(00.109338)   7471: sk unix: Opening standalone socket (id 0xd ino 0 peer 0x63b)
(00.109376)   7471: Error (criu/sk-unix.c:1128): sk unix: BUG at criu/sk-unix.c:1128

Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-12 11:44:33 +03:00
Andrey Vagin
7da537fdcb zdtm: check unix sockets in two mount namespaces
Unix file sockets have to be restored in proper mount namespaces.

Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-12 11:44:33 +03:00
Cyrill Gorcunov
a3f152be60 unix: Fix nil dereference in find_queuer_for
When walking over unix sockets make sure the
queuer is present before accessing it.

https://jira.sw.ru/browse/PSBM-82796

Reported-by: Vitaly Ostrosablin <vostrosablin@virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
2018-05-12 11:44:33 +03:00
Kir Kolyshkin
0284e70f4d scripts/build/binfmt_misc: fix for bash
There was a "; done" leftover here, somehow ignored by dash
but not bash. Remove it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-05-12 11:44:33 +03:00
Kir Kolyshkin
a2ab074eca scripts/build/Dockerfile.rawhide: rm
It is not used, probably was committed by mistake.

Fixes: 2d093a1702 ("travis: add a job to test on the fedora rawhide")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-05-12 11:44:32 +03:00
Kir Kolyshkin
c75cb2b58b CI: fix Fedora rawhide
Fix Fedora rawhide CI failure caused by coreutils-single and our
way of running under QEMU.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-05-12 11:44:32 +03:00
Kir Kolyshkin
7c4ddebc35 scripts/build/Dockerfiles: nitpicks
1. Sort lists of packages to be installed, unify indentation.

2. Merge "ccache -s" and "ccache -z".

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-05-12 11:44:32 +03:00
Kir Kolyshkin
0a4d83798b Fix zdtm with Ubuntu Bionic/arm/clang
In Ubuntu Bionic for armhf, clang is compiled for armv8l rather than
armv7l (as it was and still is for gcc) and so it uses armv8 by default.

This breaks compilation of tests using smp_mb():

> error: instruction requires: data-barriers

The fix is to add "-march=armv7-a" to CFLAGS which we already do,
except not for the tests.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-05-12 11:44:32 +03:00
Adrian Reber
780d6ea01d Print CRIU and kernel version also in RPC mode
The newly introduced output of the CRIU and kernel version does not
happen when running CRIU under RPC. This moves the print_versions()
function util.c and calls it from cr-service.c

Signed-off-by: Adrian Reber <areber@redhat.com>
2018-05-12 11:44:32 +03:00
Kirill Tkhai
001ea53388 inotify: Use fast way of obtaining desired watch descriptor number
This patch makes restore_one_inotify() to request specific
watch descriptor number instead of iterating in (possible)
long-duration loop if system supports it.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
2018-05-12 11:44:32 +03:00
Kirill Tkhai
db1f00024c kdat: Add check for inotify() INOTIFY_IOC_SETNEXTWD cmd
This is a new ioctl, which allows to request next descriptor
allocated by inotify_add_watch().

https://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs.git/commit/?h=for_next&id=e1603b6effe177210701d3d7132d1b68e7bd2c93

The patch checks this cmd is supported by kernel.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
2018-05-12 11:44:32 +03:00
Kirill Tkhai
6dd7eaccfa zdtm: Make possible to claim for features list
Currently, one feature is supported. Add possibility
for a test to depend on several features.

v2: Delete excess "if" as suggested by Andrey Vagin.
    Rename variables to decrise patch size.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-12 11:44:32 +03:00
Kirill Tkhai
3ba08939cb zdtm: Actually add tun_ns test
Previous patch missed "git add", so simlink and .desc
file were not sent...

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
2018-05-12 11:44:32 +03:00
Andrei Vagin
c90c7bd5e6 net: set_netns should set a root net ns if ns_id is zero
We need this to save backward compatibility with old images.
It is zero only if it is absent in an image file.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-12 11:44:28 +03:00
Andrew Vagin
7e355e7b12 zdtm: Add tun_ns test
tun test in nested net ns wrapper.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
ktkhai: Makefile hunks
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
2018-05-12 11:38:47 +03:00
Andrew Vagin
cd7dac19a7 net: Dump tun device net id in img
This adds new tunfile_entry::ns_id field and populates
it in standard socket way. Restore uses this ns_id
to choose correct namespace. Note, we could completelly
skip set_netns() on restore in case of !has_ns_id, but
using top_net_ns invents some definite behaviour.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
ktkhai: comment written/code movings
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
2018-05-12 11:38:46 +03:00
Kirill Tkhai
62d7780166 tun: Check that net ns of tun device is dumped
Similar to socket logic, abort the dump,
if tun is not related to any net ns, seen
before.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
2018-05-12 11:38:46 +03:00
Kirill Tkhai
fe7d8a922d tun: Check tun has ioctl() cmd SIOCGSKNS
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
2018-05-12 11:38:46 +03:00
Kirill Tkhai
8f9553a0d2 net: Extrack ioctl() call from kerndat_socket_netns()
Refactoring, no functional change.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
2018-05-12 11:38:46 +03:00
Kirill Tkhai
de25f4cebc service_fd: Place lazy pages sk to fdstore
LAZY_PAGES_SK_OF is need only once for every process,
and it's not frequently used, so we can place it
to fdstore.

https://travis-ci.org/tkhai/criu/builds/343405755

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
2018-05-12 11:38:46 +03:00
Kirill Tkhai
36ad24a193 user_ns: Prepare creds of newly created task
Sockets are sent via SCM_CREDENTIALS, and this kernel interface
needs to have uid and gid mapped (see __scm_send() in kernel).
So, set them before send_fds() use.

Also, move prep_usernsd_transport() below to be after this
for uniformity.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-12 11:38:46 +03:00
Kirill Tkhai
8fadf2b319 ns: export prepare_userns_creds()
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-12 11:38:46 +03:00
Andrei Vagin
463951aabf test: set uid_map so that INVALID_UID was out of this map
https://github.com/checkpoint-restore/criu/issues/466

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-12 11:38:46 +03:00
Pavel Emelyanov
137ce1a5fa criu: Version 3.8.1
A bug sneaked into the --shell-job restore while doing 3.8 merge.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
v3.8.1
2018-03-29 21:58:56 +03:00
Andrei Vagin
c297c994bc restore: don't call fdstore_init twice
When the "core: Init fdstore even earlier" commit was moved into
the master branch, one hunk was lost.

https://github.com/checkpoint-restore/criu/issues/460
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-27 22:52:11 +03:00
Pavel Emelyanov
c21e09cfe2 criu: Version 3.8
We've slowed down a little, but still new features and bugfixes appear.
This time we've improved lazy migration, completed SCM messages support,
added nesting netns support (now we have two of them -- net and mnt)
and did many small fixes here and there.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
v3.8
2018-03-13 15:42:34 +03:00
Dmitry Safonov
ce437d3dc5 x86/kdat: Check PTRACE_TRACEME return value
Coverity has informed:

*** CID 188251:  Error handling issues  (CHECKED_RETURN)
/criu/arch/x86/crtools.c: 196 in kdat_x86_has_ptrace_fpu_xsave_bug_child()
190             return 0;
191     }
192     #endif
193
194     static int kdat_x86_has_ptrace_fpu_xsave_bug_child(void *arg)
195     {
>>>     CID 188251:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "ptrace" without checking return value (as is done elsewhere 46 out of 51 times).
196             ptrace(PTRACE_TRACEME, 0, 0, 0);
197             kill(getpid(), SIGSTOP);
198             pr_err("Continue after SIGSTOP.. Urr what?\n");
199             _exit(1);
200     }
201

Also added checks for kill() and waitpid().

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Kirill Tkhai
b24735429b zdtm: Fix race in zdtm/transition/epoll.c test
Child may see close() result before it receives signal,
while it shouldn't see it. Instead of games with later
close(), just stop do it. sys_exit() after program finish
will close them all.

Reported-by: Andrey Vagin <avagin@virtuozzo.com>
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Andrei Vagin
900025dbda net: save all attributes of sit devices
Currently we save only attributes with non-zero values. For example,
a default value for IFLA_IPTUN_PROTO is IPPROTO_IPV6 (41), so we have to
save even attributes with zero values.

https://github.com/checkpoint-restore/criu/issues/445

Fixes: 4a044e6af9 ("net: Dump regular sit device")
Cc: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Kirill Tkhai
33c58d94d7 net: Fix namespace fd leak in get_socket_ns()
We open ns_fd via ioctl(SIOCGSKNS), but never close. Fix that.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Dmitry Safonov
a58e1f6ff9 kerndat: Separate per-arch kerndat
x86's kerndat section in crtools.c has grown too much.
Let's make it more readable and *looking at cleared include-list*,
it'll better parallelize build.

Maybe we should turn __weak function into 0-defines.
Or clean 0-defines with ifdefs in generic file.
I have no strong opinion on that.

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Mike Rapoport
455b5aea2b test/jenkins: add script for lazy migration testing
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Andrei Vagin
d499aeadf6 zdtm: enable lazy migration testing
The --lazy-migrate option allows testing of lazy migration when running ns
or uns flavor.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
2018-03-02 21:52:14 +03:00
Andrei Vagin
8c87d34575 restore: print a error if ptrace() failed
CID 85039 (#1 of 1): Unchecked return value (CHECKED_RETURN)
6. check_return: Calling ptrace without checking return value (as is done elsewhere 44 out of 49 times).

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Andrei Vagin
fd9f0aaa35 cgroup: print errors for umount and rmdir
CID 155804 (#1 of 1): Unchecked return value (CHECKED_RETURN)
2. check_return: Calling umount2 without checking return value (as is done elsewhere 8 out of 9 times).

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Andrei Vagin
526f491a26 soccr: don't leak memory on error paths
CID 172198 (#1 of 1): Resource leak (RESOURCE_LEAK)
9. leaked_storage: Variable sk going out of scope leaks the storage it points to.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Andrei Vagin
7a5d310ddc util: print all errors in a log
CID 154076 (#1 of 1): Unchecked return value from library (CHECKED_RETURN)
1. check_return: Calling setsockopt(sk, 6, 1, &val, 4U) without checking return value. This library function may fail and return an error code.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Andrei Vagin
5f94389c6b cgroups: don't leak memory on a error path
CID 161693 (#1 of 1): Resource leak (RESOURCE_LEAK)
5. leaked_storage: Variable new going out of scope leaks the storage it points to.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Pavel Tikhomirov
93b539378b criu: fix leaks detected by coverity scan part 2
*** CID 179043:    (USE_AFTER_FREE)
close bfd fd safe so that we won't have double close

*** CID 179041:  Resource leaks  (RESOURCE_LEAK)
don't forget to close fd on error

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Dmitry Safonov
31d84043ff zdtm/cgroup_ifpriomap: Fix Coverity warning
*** CID 185302:  Null pointer dereferences  (NULL_RETURNS)
/test/zdtm/static/cgroup_ifpriomap.c: 107 in read_one_priomap()
>>>     Dereferencing a pointer that might be null "out->ifname" when calling "strncpy".

There is also a warning about using rand(), but..
Not sure that we need to entangle everything just for pleasing Coverity:
>>>     CID 185301:  Security best practices violations  (DC.WEAK_CRYPTO)
>>>     "rand" should not be used for security related applications, as linear congruential algorithms are too easy to break.
Leaving that as-is and marking in Coverity as WONTFIX.

Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Dmitry Safonov
3f6145ad79 zdtm/cgroup_ifpriomap: Find cgroup's controller's name to mount
I've also dropped `noauto' in this patch, reverting the
commit be98273cf1 ("zdtm: mark static/cgroup_ifpriomap as noauto")
Don't see any sense to separate it as another patch.

Fixes: #383

Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Mike Rapoport
a91b2e90a7 page-pipe: do not allow pipe sharing between different PPB types
Currently, if pipe is shared between lazy and non-lazy PPBs lazy migration
fails because data that should be transfered on demand is spliced into the
images. Preventing pipe sharing between PPBs of different type resolves
this issue.
In order to still minimize pipe fragmentation, we track the last pipe that
was used for certain PPB type and re-use it for the PPB of the same type.

Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Dmitry Safonov
8d98d86467 zdtm/fpu02: Don't run the test on !x86 platforms
Fixes: commit 925451c12b ("zdtm/x86: Add a mxcsr preserving fpu test")

Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Andrei Vagin
4130507209 criu: fix gcc-8 warnings
criu/sk-packet.c:443:3: error: 'strncpy' output may be truncated
copying 14 bytes from a string of length 15
   strncpy(addr_spkt.sa_data, req.ifr_name, sa_data_size);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/img-remote.c:383:3: error: 'strncpy' specified bound 4096
equals destination size
   strncpy(snapshot_id, li->snapshot_id, PATHLEN);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/img-remote.c:384:3: error: 'strncpy' specified bound 4096
equals destination size
   strncpy(path, li->name, PATHLEN);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/files.c:288:3: error: 'strncpy' output may be truncated copying
4095 bytes from a string of length 4096
   strncpy(buf, link->name, PATH_MAX - 1);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/sk-unix.c:239:36: error: '/' directive output may be truncated
writing 1 byte into a region of size between 0 and 4095
   snprintf(path, sizeof(path), ".%s/%s", dir, sk->name);
                                    ^
criu/sk-unix.c:239:3: note: 'snprintf' output 3 or more bytes
(assuming 4098) into a destination of size 4096
   snprintf(path, sizeof(path), ".%s/%s", dir, sk->name);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/mount.c:2563:3: error: 'strncpy' specified bound 4096 equals
destination size
   strncpy(path, m->mountpoint, PATH_MAX);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/cr-restore.c:3647:2: error: 'strncpy' specified bound 16 equals
destination size
  strncpy(task_args->comm, core->tc->comm, sizeof(task_args->comm));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Andrei Vagin
7f5e8649b0 zdtm: fix gcc-8 warnings
fs.c:78:5: error: 'strncpy' specified bound 64 equals destination size [-Werror=stringop-truncation]
     strncpy(m->fsname, fsname, sizeof(m->fsname));
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:14 +03:00
Dmitry Safonov
7ca3005654 compel: Explicitely align all containers of i387_fxsave_struct
As it's aligned to 16, all structures that contain it should be
also aligned to 16. In the kernel there is no such align as
there two separate definitions of i387_fxsave_struct:
one for ia32 and another for x86_64.
Fixes newly introduced align warning in gcc-8.1:
In file included from compel/include/uapi/compel/asm/sigframe.h:7,
                 from compel/plugins/std/infect.c:13:
compel/include/uapi/compel/asm/fpu.h:89:1: error: alignment 1 of 'struct xsave_struct_ia32' is less than 16 [-Werror=packed-not-aligned]
 } __packed;
 ^

It doesn't change the current align of the struct, as containing
structures are __packed and it aligned already *by fact*.
It only affects the function users of the struct's local variables:
now they lay aligned on a stack.

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:13 +03:00
Dmitry Safonov
ba1b93d357 zdtm/x86: Add a mxcsr preserving fpu test
It helped a bit to debug Skylake ptrace() bug, let's put it in.

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:13 +03:00
Dmitry Safonov
d302f600a3 compel: Cleanup INFECT_* definitions
Ugh, I've spent 25 mins at 4 A.M. to figure out why the tests are failing.
And the reason is stupied me, who defined a new flag after 0x8
as 0x16, not as 0x10. Simplify those definitions for such simple-minded
living creatures like Dima.

Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-02 21:52:13 +03:00