Commit graph

758 commits

Author SHA1 Message Date
Andrew Vagin
022094db40 zdtm: typo fix
expr ns/user/static/env00 ns/user
expr: syntax error

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-11 20:21:08 +04:00
Pavel Emelyanov
8f937e0461 zdtm: Don't test userns tests if no required APIs found
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-11 20:17:57 +04:00
Andrey Vagin
5f7933e3a0 zdtm/fork: create 10 process concurrently
Currently this test creates one process and wait it. So most part of the
time this test has only one process without children.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-11 20:14:04 +04:00
Andrey Vagin
b37ce2f118 zdtm: add transition/fork2 in the test list
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-11 20:13:55 +04:00
Andrey Vagin
77bdb1828c zdtm: compare file descriptors only for static tests
For other tests set of file descriptors can be changed

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-11 20:13:49 +04:00
Andrey Vagin
6bc8b637e5 test: increase permissions for the "test" directory (v2)
Restoring mount namespaces requires to create temporary directories
in a test root.

When tests execute in a new userns, they have non-zero gid and uid,
so we need to grant permissions for them.

v2: add +rx as well

Reported-by: Mr Jenkins
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-07 23:50:47 +04:00
Andrey Vagin
f290444655 zdtm: add tests which can be executed in a new user namespace (v2)
Sockets tests are excluded, because SO_RCVBUFFORCE and SO_SNDBUFFORCE
are protected by CAP_NET_ADMIN

tty*, pty* are excluded, because TIOCSLCKTRMIOS protected by
CAP_SYS_ADMIN

*ghost, *notify, *unlink* are excluded, because linkat(AT_EMPTY_PATH)
are protected by CAP_DAC_READ_SEARCH

v2: use a blacklist
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-07 17:20:48 +04:00
Andrey Vagin
b109e9ef11 zdtm: add ability to execute tests in another user namespace
v2: don't forget to initialize groups
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-07 17:20:21 +04:00
Andrey Vagin
0014a12d96 zdtm: prepare a file tree for userns
Here are two issues:
1. All mounts in a new user namespace are locked, so
we need to create a new root mount. We need to bind-mount root to
itself.
2. /proc and /sys must be mounted before umounting /proc and /sys
which were inhereted. It's a security policy.

"""
Author: Eric W. Biederman <ebiederm@xmission.com>
Date:   Sun Mar 24 14:28:27 2013 -0700

    userns: Restrict when proc and sysfs can be mounted

    Only allow unprivileged mounts of proc and sysfs if they are already
    mounted when the user namespace is created.
"""

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-07 17:19:45 +04:00
Andrey Vagin
ed5a1ba122 zdtm: create devices before forking a test process
Devices can not be created in a new user namespace.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-07 17:19:36 +04:00
Andrey Vagin
41b972ccbc jenkins: check page-server (v2)
page-server are not tested now. I suggest to add it in the pre-dump job.

v2: execute all tests with and without page server
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-06 15:25:07 +04:00
Andrey Vagin
2491da9219 page-xfer: write pidfile from a process which starts a service
When a process, which starts a service, exits, we know that we can
connect to the page server and we expect to find pidfile.

If we create pidfile from a page server process, we have a race window.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-05 15:42:50 +04:00
Andrey Vagin
1ca3317edc zdtm: improve checking file descriptors and memory regions (v2)
Now we check them for all test processes

v2: Busybox doesn't have truncate
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-30 15:14:00 +04:00
Cyrill Gorcunov
9da5531c81 test: Add console trivial test
We simply check that major/minor didn't changed after restore.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-27 21:35:42 +04:00
Andrey Vagin
deeea1d221 zdtm/socket-tcpbuf: heartbeat should not read all data
Currently we fill as much as posible data in a socket and then use
half of these data to make a flow in the connection.

These data is send and recv buffers. When a connection is dumped and
restored, it needs time to go back to the normal work. In this time we
can reliably fill only send buffers. So at the result the sockets may
contain less data than required for heartbeating and the test will
block.

The test with this patch will monitor actuall size of data in a test
socket.

Cc: Konstantin Neumoin <kneumoin@parallels.com>
Reported-by: Konstantin Neumoin <kneumoin@parallels.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-27 21:31:09 +04:00
Andrey Vagin
02d9bd1093 zdtm: check that process w/o file descriptors can be dumped and restored
In addition it checks that criu closes all its descriptors

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-27 21:29:21 +04:00
Cyrill Gorcunov
d7865bee7a test: shm -- Make sure SysV memory restored properly
In criu we carry SysV memory via @VMA_AREA_SYSVIPC
attribute but to the test must have a live reference
to real memory area to check that shmem address was
restored correctly. Add it.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-27 21:26:45 +04:00
Andrey Vagin
406b6b4237 zdtm: always show errors
Users don't like errors even if criu returns zero.
So I suggest to start looking at them.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 20:15:11 +04:00
Andrey Vagin
f32fa08d0f zdtm/Makefile: show output for each test
In this case we have another chance to not skip errors.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 20:13:50 +04:00
Konstantin Neumoin
3ecd7f2d14 zdtm:Makefile increase wait timeout
This timeout is too small for tcp test cases.
This timeout should be bigger than TCP_RTO_MAX 120 seconds

Signed-off-by: Konstantin Neumoin <kneumoin@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 20:03:21 +04:00
Andrey Vagin
6084e1d08b zdtm/static/xids00: print more information about errors (v2)
v2: typo fix
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 20:02:29 +04:00
Andrey Vagin
1a3fc94c57 zdtm/maps01: extend maps01
It's bad idea to have only one target object.
In addition I add a shared region to the second process,
which is not mapped in the first.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 19:57:14 +04:00
Konstantin Neumoin
c4a06a2a26 zdtm/stopped: fix stopped test
The main problem with the
test that it's never 'fail'.
Test can only 'pass' or hangs.

Signed-off-by: Konstantin Neumoin <kneumoin@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-09 19:17:59 +04:00
Andrey Vagin
9391034f12 zdtm.sh: don't change owner of a test directory
After changing an owner the current user will not be able to remove or
change the directory. It isn't convenient.

Reported-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-07 15:45:35 +04:00
Andrey Vagin
82d509cb48 zdtm: don't execute pipe00 a few times simultaneously
zdtm-pre-dump, zdtm-snapshot, zdtm-iter, zdtm execute pipe00, so
these targets should be executed one by one.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-07 15:45:11 +04:00
Nicolas Dichtel
25e1997fde test/zdtm: fix compilation of maps02.c when MADV_DONTDUMP is unknown
Error was:
maps02.c: In function ‘main’:
maps02.c:57:74: error: ‘MADV_DONTDUMP’ undeclared (first use in this function)
maps02.c:57:74: note: each undeclared identifier is reported only once for each function it appears in
make: *** [maps02] Error 1
ERROR: fail to start /home/root/criu/test/zdtm/live/static/maps02

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-03 18:57:32 +04:00
Andrey Vagin
f582f16db0 test: expand the default test set
* check page server
* check snapshots
* check a few iterations of dump/restore

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-02 14:58:37 +04:00
Andrey Vagin
6694403214 zdtm/tempfs: set mode for O_CREAT
man 2 open:
"""
mode specifies the permissions to use in case a new file is cre‐
ated.  This argument must be supplied when O_CREAT or O_TMPFILE
is specified in flags;
"""

Cc: Konstantin Neumoin <kneumoin@parallels.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-30 21:55:01 +04:00
Andrey Vagin
c7390d2d3f zdtm/cwd01: don't forget to set '\0' after readlink()
Reported-by: Konstantin Neumoin <kneumoin@parallels.com>
Cc: Konstantin Neumoin <kneumoin@parallels.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-30 21:54:34 +04:00
Ruslan Kuprieiev
3b2ab35bc8 test: rpc: test page-server
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-22 16:30:48 +04:00
Andrey Vagin
eda6b3d002 zdtm: don't call mount_cgroups a few times concurrently
Here is a race now:
./zdtm.sh --ct -d -C -x static/cgroup02 ns/static/pipe02 &> ns_static_pipe02.log || \
{ flock Makefile cat ns_static_pipe02.log; exit 1; }
./zdtm.sh --ct -d -C -x static/cgroup02 ns/static/busyloop00 &> ns_static_busyloop00.log || \
{ flock Makefile cat ns_static_busyloop00.log; exit 1; }
make[3]: `zdtm_ct' is up to date.
mkdir: cannot create directory ‘zdtm.GgIjUS/holder’: File exists

Reported-by: Mr Jenkins
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-22 12:15:45 +04:00
Pavel Tikhomirov
8b9e18f07b zdtm: test for mlocked area restores if programm have no credentials
Test maps 17 pages and mlocks them, then changes user id from root
to 18943, after c/r checks that MAP_LOCKED bit is set for that vma.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-19 17:44:28 +04:00
Pavel Tikhomirov
2f85727410 zdtm: move get_smaps_bits to separate file for reuse
Signed-off-by: Pavel Tikhomirov <ptikhomirov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-19 17:44:26 +04:00
Tycho Andersen
e9d0499cd1 test: add a test for remap_dead_pid
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-19 17:42:49 +04:00
Matthias Neuer
fc983814cc fixed kernel version detection
My debian testing produces the following output for uname:
$ uname -r
3.14-2-amd64

and so:
$ set -- `uname -r | sed 's/\./ /g'`
$ echo $1
3
$ echo $2
14-2-amd64

this causes zdtm.sh to fail for me on line 293:
[ $1 -eq 3 -a $2 -ge 11 ] && return 0

because "14-2-amd64 -ge 11" is false.

Signed-off-by: Matthias Neuer <matthias.neuer@uni-ulm.de>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-18 20:17:51 +04:00
Konstantin Neumoin
7493eef982 zdtm: fix msg reporting
avoid err() for regular msg reporting

Acked-by: Andrew Vagin <avagin@parallels.com>

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-12 14:02:03 +04:00
Andrey Vagin
7576898243 zdtm/mountpoints: add "unknown" options to reproduce the previous bug
tmpfs has the "size" option, which is not standard.

Execute zdtm/live/static/mountpoints
./mountpoints --pidfile=mountpoints.pid --outfile=mountpoints.out
Dump 2737
WARNING: mountpoints returned 1 and left running for debug needs
Test: zdtm/live/static/mountpoints, Result: FAIL
==================================== ERROR ====================================
Test: zdtm/live/static/mountpoints, Namespace:
Dump log   : /root/git/criu/test/dump/static/mountpoints/2737/1/dump.log
--------------------------------- grep Error ---------------------------------
(00.146444) Error (mount.c:399): Two shared mounts 50, 67 have different sets of children
(00.146460) Error (mount.c:402): 67:./zdtm_mpts/dev/share-1 doesn't have a proper point for 54:./zdtm_mpts/dev/share-3/test.mnt.share
(00.146820) Error (cr-dump.c:1921): Dumping FAILED.
------------------------------------- END -------------------------------------
================================= ERROR OVER =================================

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Tested-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-10 18:33:10 +04:00
Andrey Vagin
5fcebf2d7e zdtm/inotify00: fix expected sets of events
zdtm.sh with zero iterations of dumping/restoring checks correctness of
tests.

$ bash test/zdtm.sh -i 0 zdtm/inotify00
Output file: /root/git/orig/criu/test/zdtm/live/static/inotify00.out
------------------------------------------------------------------------------
19:16:29.601:  6905: 	unlink 02       : event      0x200 -> IN_DELETE
19:16:29.602:  6905: 	unlink 02       : event      0x200 -> IN_DELETE
19:16:29.602:  6905: 	unlink 02       : event        0x8 -> IN_CLOSE_WRITE
19:16:29.602:  6905: 	unlink 02       : event        0x8 -> IN_CLOSE_WRITE
19:16:29.602:  6905: 	unlink 02       : event      0x400 -> IN_DELETE_SELF
19:16:29.602:  6905: 	unlink 02       : event     0x8000 -> IN_IGNORED
19:16:29.602:  6905: 	unlink 02       : read  6 events
19:16:29.614:  6905: 	after           : event        0x8 -> IN_CLOSE_WRITE
19:16:29.614:  6905: 	after           : read  1 events
19:16:29.614:  6905: FAIL: inotify00.c:217: Unhandled events in emask 0x200 -> IN_DELETE (errno = 11 (Resource temporarily unavailable))
------------------------------------- END -------------------------------------
================================= ERROR OVER =================================

This patch removes logic about linked files, because it's useless.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-05 19:41:47 +04:00
Konstantin Neumoin
61dbc97643 zdtm: fix /proc/lock parsing
11: POSIX  ADVISORY  WRITE 1 b6:a4111:136512 0 EOF
Acked-by: Andrew Vagin <avagin@parallels.com>

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-05 16:01:39 +04:00
Cyrill Gorcunov
68138cf3d1 test: inotify00 -- Rework test, v2
To show which events are coming and flush events before dump as required by new fsnotify mode.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-04 15:42:56 +04:00
Andrey Vagin
67cc8be34d zdtm: mount test cgroup controllers before executing tests
If a controller is mounted during dumping processes, criu may fail with error:
Error (cgroup.c:768): cg: Set 3 is not subset of 2

so lets create all test controllers before executing tests.

Reported-by: Mr Jenkins
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-03 21:08:07 +04:00
Tycho Andersen
ae3cb4fb1f restore: open the pidfile with O_EXCL
There is a potential attack here where if someone is restoring something and
criu write the pid to a file the attacker controls, the attacker can then
re-write that to whatever pid they want. ciru should instead open the file with
O_EXCL so that the restore fails if the file exists.

We don't need O_TRUNC here since we're O_EXCL-ing the file.

Reported-by: Serge Hallyn <serge.hallyn@ubuntu.com>
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-09-03 20:58:24 +04:00
Pavel Emelyanov
e523b371c7 test: Don't compare PIDs when searching for our locks
Criu may re-lock the lock, thus spoiling the pid, so compare
the file inode number instead.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 19:09:47 +04:00
Pavel Emelyanov
2c765509f5 test: Check that criu's donwgrading quirk works
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:58 +04:00
Pavel Emelyanov
96e6ea5ae7 test: Check that overlapping locks work
If we open a file, lock one, fork, then close and
open the file in parent again, lock should 'slide'
to the child process anyway.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:54 +04:00
Pavel Emelyanov
92a7cf59ad test: Check that inherited flocks work
Inherited flock is the one that a task got from its parent.
In case parent closes the corresponding fd, the /proc/locks
still shows the parent pid, while the lock is owned by child.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:53 +04:00
Pavel Emelyanov
b593024dd6 test: Check that shared locks work
Shared here means that a flock is visible from two tasks -- the
owner one and its child.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:50 +04:00
Andrey Vagin
c5d238ef66 zdtm/fanotify00: use /tmp instead of /
Usually /tmp is a mount point.

Recently we found a bug in criu, when it restore mount fanotify on "./"
instead of "/". The test didn't find it, because they are pointed on the
same mount point.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:12:32 +04:00
Andrey Vagin
473a81df74 zdtm: chech that a mark is restored on a correct mount point
We try to remove mark on the correct mount point and
if the mark is restored on a wrong mount point, we will get ENOENT.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:12:16 +04:00
Andrew Vagin
dd63975bdc test: don't clean up submounts (v2)
I'm scared, when I see smth like that:
rm: cannot remove ‘/var/lib/jenkins/jobs/CRIU/workspace/test/dump/static/cgroup00/31195/1/.criu.cgyard.6qctPl/systemd/tasks’: Operation not permitted

v2: do that only in the "test" directory

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:11:02 +04:00