Commit graph

5943 commits

Author SHA1 Message Date
Cyrill Gorcunov
a38bf75d1e arch: ppc64 -- Wire in ptrace syscall
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-04 11:41:43 +03:00
Cyrill Gorcunov
cd48bddb52 cr-check: Don't include sys/syscalls.h
This conflicts with predefined constants in our own syscalls lib.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-04 11:41:26 +03:00
Cyrill Gorcunov
fca60130f6 arch: x86 -- Add sys_ptrace declaration
We will need it for cr-check.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
iAcked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-04 11:41:20 +03:00
Pavel Emelyanov
12db8a47c3 zdtm.py: Get 'sat' option with .get method
When using non-run command the 'sat' option is not in opts dict,
so it should be checked with softer method.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-03 18:46:25 +03:00
Pavel Emelyanov
327f835d37 zdtm: Mark mountpoints as exclusive
This test does nasty things with the root it runs in, in
particular is kills and creates /dev/null which may result
in /dev/null become 'deleted' for the tests running in
paralles with this. The lattest is critical for uns flavor
as ghost /dev/null will not be re-created (mknod fails).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-03 18:21:48 +03:00
Pavel Emelyanov
3c0eec4814 zdtm.py: Create /dev/net in ns root
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-03 15:50:45 +03:00
Pavel Emelyanov
14f0eabe48 zdtm: Remove ZDTM_REEXEC (v2)
Also remove now unused skip_pid label.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
2015-12-03 14:56:28 +03:00
Pavel Emelyanov
9d6bc6e4e0 zdtm: Remove test_init_ns()
The ns and uns flavors are MUCH better ways of launching tests in namespaces.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
2015-12-03 14:56:19 +03:00
Pavel Emelyanov
c31c594e74 zdtm: Stop using test_init_ns by static/mountpoints
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
2015-12-03 14:56:02 +03:00
Pavel Emelyanov
287b14655e zdtm: Stop using test_init_ns by transition/ipc
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
2015-12-03 14:55:54 +03:00
Pavel Emelyanov
a2b1e9ae05 zdtm: Mark some functions as static
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-03 14:55:24 +03:00
Pavel Emelyanov
166162dca7 zdtm: Cleanup uid setup check in ns creation code
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-03 14:55:18 +03:00
Pavel Emelyanov
6460badfdf zdtm: Construct all root dirs and files in launcher
Instead of doing some dirs/files/links in launcher and some in
libzdtm, make everything in the launcher. The library is then
just to set up the namespaces.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-03 14:55:13 +03:00
Tycho Andersen
bfb24cec8b zdtm.py: don't umount in clean_tests_root
If we get EBUSY here, it means that we didn't umount in the test (i.e. we
didn't call fini() on some path). We should just do that instead.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-03 14:54:40 +03:00
Tycho Andersen
10f33eeca7 ipv6: only save scopeid when it is required
The kernel only requires that we supply a scope id to bind() when the
source address is of certain types, so lets only save/supply the scope id
in these cases.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-03 14:54:25 +03:00
Tycho Andersen
ac6641033d tests: skip seccomp_filter_tsync if __NR_seccomp isn't defined
This change does two things to be more defensive: 1. add a checkskip script
which fails if __NR_seccomp isn't defined, and 2. allows
seccomp_filter_tsync to compile even if it isn't defined (and then fails
"gracefully" with a skip message if it does).

The checkskip bits are necessary because zdtm.sh gets confused if the test
exits 0 without actually invoking criu.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-02 17:19:08 +03:00
Andrew Vagin
b352659ca2 criu: don't trigger a bug if a task wants to restore a root mntns
It's possiable, if a parent task lives in a sub-mntns and
its child lives in the root mntns. A mount namespace is
restored before forking children, so all children are created
in parent's mount namespace. If a child lives in another
mount namespace, we need to move it into the required mntns.

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-30 11:49:15 +03:00
Andrew Vagin
f73802fe6d zdtm: check a case when a task is in sub-mntns, its child is in root mtnns
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-30 11:48:54 +03:00
Tycho Andersen
a1d06e53f6 test: add bind() test to bridge
This tests c/r of the link-local scope-id argument to bind().

v2: sort the interfaces so diff works

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-30 11:46:34 +03:00
Tycho Andersen
7209c4ec28 inet: remember ipv6 connections' ifindex for restore
For some ipv6 scope types (link local, amongo others), we need to tell the
kernel the ifindex of the interface whose address we want to bind to as
well as the address itself.

v2: use SO_BINDTODEVICE to get the ifname, and pass that through instead of
    using netlink to grab all the ipv6 sockets via rtnetlink.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-30 11:46:16 +03:00
Pavel Emelyanov
c1b1880b34 zdtm: Check how auto-dedup works
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-30 11:44:57 +03:00
Andrew Vagin
df006762f0 check: don't use uninitialized variables
CID 154853 (#1 of 1): Uninitialized scalar variable (UNINIT)
7. uninit_use_in_call: Using uninitialized value c when calling write.

Reported-by: coverity
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-30 11:40:29 +03:00
Andrew Vagin
d1ee2801c6 files-reg: don't leak a file descriptor
CID 154850 (#1 of 1): Resource leak (RESOURCE_LEAK)
9. leaked_handle: Handle variable cwd_fd going out of scope leaks the handle.

Reported-by: coverity
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-30 11:40:07 +03:00
Andrew Vagin
d55e13d4f3 seccomp: don't leak info on an error path
CID 154852 (#1 of 3): Resource leak (RESOURCE_LEAK)
32. leaked_storage: Variable info going out of scope leaks the storage it points to.

Reported-by: coverity
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-30 11:39:43 +03:00
Tycho Andersen
1bd799ef30 tests: remove unused bpf.h
This header is unused, and not present on kernels w/o CONFIG_BPF_SYSCALL,
so let's not require it.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-27 15:50:41 +03:00
Andrew Vagin
af956f45ac mount: close mnt.ns_fd only for sub-namespaces (v3)
nsid->mnt.ns_fd is initialized into 0, so currently
fini_restore_mntns() closes the 0 descriptor if processes
lives in a current mount namespace (NS_CRIU).

Without this patch I get the following error:
(00.166444)   4109: Inherit fd tty:[8800:d] -> 0 has been closed

v2: typo fix
v3: do nothing when processes are restored in the local mntns
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-27 15:50:09 +03:00
Andrew Vagin
973731037e zdtm: compile stopped12
stopped03 is an old name of stopped12

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-27 15:49:08 +03:00
Tycho Andersen
c399e72d43 gitignore: ignore more test binaries
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 21:09:01 +03:00
Andrew Vagin
7828bbc351 seize: don't use wait4() to check whether or not a task is traced
If a task is stopped, waitpid() will return its status, but
wait4() in seize_wait_task will hang forever, because a stopped
state is reported only once.

v2: don't like a file object

Reported-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 21:08:54 +03:00
Andrew Vagin
708e2b37b3 seize: increase timeout of freezing processes
The timeout between iterations should be the save oder
with scheduler timeslice, which is about 100 msec.

Currently we wait for inly 10 msec, which is obviously not enough.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 21:08:35 +03:00
Pavel Emelyanov
bf039b7735 zdtm: Fix compilation after vfork test adding
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 17:25:19 +03:00
Andrew Vagin
49448676ac util: don't leak cr-img objects (v2)
We need to call close_image() for "empty" images.

v2: don't touch generic functiuons
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 17:04:37 +03:00
Andrew Vagin
490021ef9c restore: remove an unused label
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 17:04:01 +03:00
Pavel Ganyushin
22d4ec3ae1 Migration with vfork
This is old missed test. Fail expected.

Signed-off-by: Pavel Ganyushin <pganyushin@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 17:03:31 +03:00
Andrew Vagin
5df2358f95 zdtm/stopped: check more cases
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 09:05:15 +03:00
Andrew Vagin
fa79ffd6ed ptrace: skip all sigstop (v2)
A task can be stopped and has a queued SIGSTOP, in this case we need
to resume the task twice to skip "both" signals.

v2: detect SIGSTOP in shared and per-process queues
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 09:05:13 +03:00
Andrew Vagin
fde1116fee proc: parse sigpnd and shdpnd separatly
We found that we want to know whether SIGSTOP is queue
in both or is in one of this queues.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 09:05:12 +03:00
Andrew Vagin
32452b2111 zdtm.py: umount root only if it was mounted
We get the stack trace if a test failed:

Test output: ================================
09:11:34.584:     4: PASS

 <<< ================================
Traceback (most recent call last):
  File "zdtm.py", line 922, in <module>
    do_run_test(tinfo[0], tinfo[1], tinfo[2], tinfo[3])
  File "zdtm.py", line 696, in do_run_test
    t.kill()
  File "zdtm.py", line 302, in kill
    self.__flavor.fini()
  File "zdtm.py", line 168, in fini
    subprocess.check_call(["mount", "--make-private", self.root])
  File "/usr/lib64/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['mount', '--make-private', '/tmp/criu-root-YN1t3X']' returned non-zero exit status 32
umount: /tmp/criu-root-YN1t3X: not mounted

Cc: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-25 15:30:32 +03:00
Andrew Vagin
6cc316615c ptrace: send SIGSTOP to restore the stopped state
If a task was in a stopped state before we started to ptrace-seize
it, this stopped state will be restored by kernel upon detach.

If SIGSTOP was only in a task queue, we need to send it by hands
again bedore detaching. Otherwise we clean stop from queue (to
run parasite) and seize will restore task as running.

And, since SIGSTOP doesn't affect states of already stopped tasks,
we can send it to then safely and not distinguish stopped from
stop-queued ones.

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-25 15:28:56 +03:00
Pavel Emelyanov
8135e26ae3 jenkins: Fix path to zdtm.py in criu-fault
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-23 13:22:08 +03:00
Andrew Vagin
46daab0baf zdtm: check that the IP_FREEBIND is restored correctly
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-23 12:42:53 +03:00
Pavel Emelyanov
e6859679cd jenkins: Mark criu-fault test as executable
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-23 12:42:22 +03:00
Pavel Emelyanov
2b5a11a7a3 jenkins: Add job for known fault injections (v2)
v2: Add --report for report generation

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
2015-11-23 11:48:23 +03:00
Tycho Andersen
e6a3aef43e remap: don't allocate dead pids in wrong context
Closes #87

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-23 11:47:29 +03:00
Andrew Vagin
73a739b8d3 inet: set IP_FREEBIND before binding socket to an ipv6 address (v2)
When we restore ipv6 addresses, they go through a “tentative” phase
and sockets could not be bound to them in this moment.

v2: add more comments in code

Reported-by: Ross Boucher <boucher@gmail.com>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-23 11:46:38 +03:00
Andrew Vagin
c9a61a205f sk-inet: handle the IP_FREEBIND option (v2)
v2: set has_freebind
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-23 11:46:29 +03:00
Tycho Andersen
c2ad6f3a68 check: drop bpf.h include
This include is actually unused (probably leftover from an old version of
the kernel API when I was porting the patchsets); we can delete it.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-23 11:45:05 +03:00
Tycho Andersen
cc9587ffc5 seccomp: is optional when parsing /proc/pid/status
Also define some constants for people who don't have them in their headers.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-23 11:44:50 +03:00
Pavel Emelyanov
3364992dc1 thread-bomb: Do not run automatically by .py
This teat crashes the ptrace-based freezer, need freeze-cgroup

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-20 21:58:17 +03:00
Tycho Andersen
f10de707a2 --freeze-cgroup: should also seize tasks in sub-cgroups
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Andrew Vagin <avagin@virtuozzo.com>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-20 21:30:11 +03:00