Commit graph

5120 commits

Author SHA1 Message Date
Andrey Vagin
a2e0acfdcb cow01: try to read a page to take it from a swap
Vladimir said that a page can be unmapped from one process, but can be
mmaped in another one. In this case we can't understand whether both
processes link to the same page or they don't.

So we can try read both pages to take them from swap.

Cc: Vladimir Davydov <vdavydov@parallels.com>
Reported-by: Parallels' QA
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-24 10:59:50 +03:00
Andrey Vagin
bda4dfd173 test: add cow01 into TEST_SUID_LIST
cow01 uses /proc/pid/pagemap which has been protected by
CAP_SYS_ADMIN.

"""
	commit	ab676b7d6fbf4b294bf198fb27ade5b0e865c7ce
	pagemap: do not leak physical addresses to non-privileged userspace

	As pointed by recent post[1] on exploiting DRAM physical imperfection,
	/proc/PID/pagemap exposes sensitive information which can be used to do
	attacks.
"""

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-23 17:42:03 +03:00
Oleg Nesterov
07dcf0dbb6 restore/x86: restore_gpregs() needs to initialize ->ss as well
Before the recent "x86_64,signal: Fix SS handling for signals delivered
to 64-bit programs" kernel patch, sigreturn paths forgot to restore ->ss
after return from the signal handler.

Now that the kernel was fixed, restore_gpregs() has to initialize ->ss
too, it is no longer ignored.

Note: this is the minimal fix. In the long term we probably should not
dump/restore the segment registers at all. We can use sigcontext filled
by the target kernel and modify the general-purpose regs.

Reported-and-tested-by: Andrey Wagin <avagin@gmail.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-20 16:29:59 +03:00
Ruslan Kuprieiev
044011e579 reg-files: skip size for O_APPEND|O_WRONLY files, v2
This is common for log files, when a number of processes
are writing something into one file. Currently, if someone
wrote something to log since dump happened, on restore criu
will complain about "File has bad size" and refuse to restore.

If file is opened with O_APPEND|O_WRONLY flags it is going to
jump to the EOF anyway.

v2, use O_ACCMODE and separate helper

Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-20 16:29:37 +03:00
Pavel Emelyanov
c625b4fbc9 doc: Remove -t from restore command
It's obsoleted and is not required.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-19 13:18:13 +03:00
Kirill Tkhai
83f7e667d9 tests: Add more debug info to caps00 test
Print all cap values in case of test is failed.
Also check for capset() and capsget() return values.

Signed-off-by: Kirill Tkhai <ktkhai@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-18 22:41:11 +03:00
Saied Kazemi
140d65ebca Dismantle cgyard in non-detached restore mode.
If the --restore-detached command line option is not specified during
restore, CRIU should unmount and remove the temporary cgyard directory
tree before waiting for the restored process to exit.  Otherwise, all
the temporary cgyard mount points will remain mounted and visible.

Signed-off-by: Saied Kazemi <saied@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-18 22:39:57 +03:00
Andrey Vagin
a66217a253 image: open lazy images in img_raw_fd()
Lazy images are opened on a first attempt of using.

00:01:18.534 Test: zdtm/live/static/pipe00, Result: FAIL
00:01:18.537 ==================================== ERROR ====================================
00:01:18.538 Test: zdtm/live/static/pipe00, Namespace: 1
00:01:18.538 Dump log   : /var/lib/jenkins/jobs/CRIU/workspace/test/dump/ns/static/pipe00/13536/1/dump.log
00:01:18.540 --------------------------------- grep Error ---------------------------------
00:01:18.543 (00.026666) Error (include/image.h:153): BUG at include/image.h:153
00:01:18.543 (00.050663) Error (namespaces.c:801): Namespaces dumping finished with error 134
00:01:18.543 (00.050918) Error (cr-dump.c:1979): Dumping FAILED.
00:01:18.545 ------------------------------------- END -------------------------------------
00:01:18.548 ================================= ERROR OVER =================================

Reported-by: Mr Jenkins
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-16 17:17:04 +03:00
Pavel Emelyanov
8ce37e676a img: Don't create empty images
Currently on dump we generate too many image files, effectively
all the stuff from the GLOB set is created. The thing is that
sometimes some of created images can be empty (just contain the
magic number at the head). Thos images are useless and just
waste the space.

When applied after the "empty images" set, this introduces the
lazy images -- when we call open_image() the actual file is
only created (and the magic number is written into it) when the
very first object goes into it.

For example for the simplest test we have, then static/env00
one, the created image files are

   core-7290.img
   creds-7290.img
   fdinfo-2.img
   fs-7290.img
   ids-7290.img
   inventory.img
   mm-7290.img
   pagemap-7290.img
   pages-1.img
   pstree.img
   reg-files.img
   sigacts-7290.img

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-16 15:58:32 +03:00
Pavel Emelyanov
7ede4697cf bfd: Don't leak image-open flags into bfdopen
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-16 15:58:14 +03:00
Pavel Emelyanov
f7f76d6ba6 img: Introduce empty images
When an image of a certian type is not found, CRIU sometimes
fails, sometimes ignores this fact. I propose to ignore this
fact always and treat absent images and those containing no
objects inside (i.e. -- empty). If the latter code flow will
_need_ objects, then criu will fail later.

Why object will be explicitly required? For example, due to
restoring code reading the image with pb_read_one, w/o the
_eof suffix thus required the object to be in the image.

Another example is objects dependencies. E.g. fdinfo objects
require various files objects. So missing image files will
result in non-resolved searches later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-13 14:42:54 +03:00
Pavel Emelyanov
45a0cc4234 page-read: Explicitly mark ENOENT with return code
When page-read fails to open the pagemap image it reports error.
One place (stacked page-reads) need to handle the absent images
case gracefully, so fix the return codes to make this check
work.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-13 14:42:11 +03:00
Pavel Emelyanov
e29c9daec2 img: Remove O_OPT and COLLECT_OPTIONAL
Current code doesn't make any difference between OPT and no-OPT
except for the message is printed or not in the open_image().
So this particular change changes nothing but the availability of
this message.

In the next patches I wil introduce "empty images" to deal with
the ENOENT situation in a more graceful manner.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-13 14:42:01 +03:00
Cyrill Gorcunov
8218e014d0 pie: parasite -- Drop dangling \Tab
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-13 14:33:16 +03:00
Cyrill Gorcunov
290211fb94 tty: Aligh tty_driver members
As done for other structures here in file.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-10 21:16:40 +03:00
Cyrill Gorcunov
19948472d9 tty: Rename tty_type to tty_driver
There are too many "type" in code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-10 21:16:22 +03:00
Cyrill Gorcunov
819f41eaa5 tty: Drop dangling \Tab
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-10 21:16:15 +03:00
Cyrill Gorcunov
652fbf3bd1 tty: Drop redundant constants
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-10 21:16:10 +03:00
Pavel Emelyanov
f32f4ffa76 img: Open images for dump in O_WRONLY mode
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-09 22:21:15 +03:00
Pavel Emelyanov
618c17b6f8 img: Simplify the open_image() macro
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-09 22:21:08 +03:00
Pavel Emelyanov
131d4b8691 mem: Sanitize error path in prepare_mappings()
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-09 22:20:33 +03:00
Pavel Emelyanov
fce8cac1df mem: Move private vmas maping code into subroutine
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-09 22:20:07 +03:00
Pavel Emelyanov
dceb6633c7 page-read: Introduce custom flags for opening
Instead of open flags and boolean is_shmem argument.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:50:32 +03:00
Pavel Emelyanov
7c7d50fb98 util-fd: Use standard BUG_ON instead of hand-made
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:50:06 +03:00
Cyrill Gorcunov
0328d33e62 test: posix_timers -- Beautify code and output
- easier to read @posix_timers
 - more verbose logging is convernient for handling errors

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:49:29 +03:00
Cyrill Gorcunov
3bd6d9d7b0 image: Add comments about VMA_AREA constants and drop FORCE_READ flag
Force-read came from very first dev version of CRIU (even before 1.0 release)
and never been used actually in image.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:48:47 +03:00
Pavel Emelyanov
48032d8780 tty: Introduce TTY_MASTER flag
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:47:40 +03:00
Pavel Emelyanov
bc535380de tty: Sanitize ctl terminal restore codeflow
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:47:38 +03:00
Pavel Emelyanov
d47975b5ec tty: Move image type onto tty_type
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:47:36 +03:00
Pavel Emelyanov
3b913082ac tty: Introduce per-type flags
And start making and using the TTY_PAIR one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:47:34 +03:00
Pavel Emelyanov
a7631ed8f9 tty: Put open() callback on tty_type
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:47:09 +03:00
Pavel Emelyanov
c314ffbe69 tty: Per-type img_get_index callback
This one is used on restore (and for static indices
the constant value is used too).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:47:08 +03:00
Pavel Emelyanov
bced873181 tty: Per-type fd_get_index callback
This one gets index from fd/fd_parms pair on dump. For
console and vt the index is constant and just sits on
the tty_type (will also be used on restore, see next
patch).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:47:07 +03:00
Pavel Emelyanov
a9ae0ab6d9 tty: Put tty name on tty_type
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:47:06 +03:00
Pavel Emelyanov
057f00ce92 tty: Make tty type be object rather than integer
The plan is to replace tons of if (type == TTY_TYPE_FOO) checks
with type->something dereferences.

To do this, start with replacing int type with struct tty_type *
in relevant places and fixing compilation.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:47:04 +03:00
Pavel Emelyanov
a7601d6a50 tty: Move tty_type() and is_pty() to tty.c
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:46:16 +03:00
Pavel Emelyanov
3a25abdad2 tty: Use tty_name in prints
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-04 17:45:08 +03:00
Pavel Emelyanov
9f0e6c0e59 criu: Version 1.5
Here it is. The major new thing I think is the CRIT tool
that will be the main one to mainupulate images and will
eventually replace the "criu show" action.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-03-02 15:37:01 +03:00
Andrey Vagin
6c6854b5e9 zdtm: add debug to investigate fails of maps007
Reported-by: Mr Jenkins
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-02-27 16:29:36 +03:00
Andrey Vagin
1d7ed7dfab zdtm: set ZDTM_NOSUBNS when a specified test is executed
Reported-by: Mr Jenkins
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-02-25 18:40:19 +03:00
Pavel Emelyanov
90b2c9b472 zdtm: Print /proc/locks in lock tests to investigate random failures
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-02-25 11:46:46 +03:00
Pavel Emelyanov
e10b3ef407 mount: Don't ignore validation and shared resolving errors on dump
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-02-25 11:46:26 +03:00
Andrey Vagin
9fa75831c7 zdtm: don't use sleep for synchronization in zombie00
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-02-25 11:13:28 +03:00
Andrey Vagin
d12317ded3 ptrace: call wait only if PTRACE_SEIZE was successful
and print errno for the wait syscall in an error case

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-02-24 21:44:23 +03:00
Andrey Vagin
99801e72f0 proc: parse /proc/pid/status when a task is stopped (v2)
If we parse /proc/pid/status when a task isn't stopped,
we can't be sure that a process state will not be changed.

08:58:48 Test: zdtm/live/user/static/zombie00, Namespace: 1
08:58:48 Dump log   : /var/lib/jenkins/jobs/CRIU-dump/workspace/test/dump/ns/user/static/zombie00/114/1/dump.log
08:58:48 --------------------------------- grep Error ---------------------------------
08:58:48 (00.001127) Error (ptrace.c:124): SEIZE 121: task not stopped after seize

v2: don't believe into errno (by xemul@)

Reported-by: Mr Jenkins
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-02-24 16:53:14 +03:00
Cyrill Gorcunov
9be7769017 tty: Fix typo in tty_setup_slavery for VT
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-02-20 00:11:47 +03:00
Cyrill Gorcunov
bec5a023d1 tty: Fix mistyping of /dev/tty
/dev/tty stands for current terminal which we don't yet
implemented a support for.

This is a bugfix for upcoming stable version, the proper
support of /dev/tty is gonna be implemented separately.

Reported-by: Saied Kazemi <saied@google.com>
CC: Andrew Vagin <avagin@parallels.com>
CC: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-02-20 00:11:38 +03:00
Andrey Vagin
2ecc25ef5e zdtm: clean a test root before executing tests in userns
A tests is executed from different users in cases with and without
userns, so it can't to open files which were created before.

Here is an example for ns/user/static/inotify_irmap:
13355 mkdir("/etc", 0600)               = -1 EEXIST (File exists)
13355 unlink("/etc/zdtm-test")          = -1 EACCES (Permission denied)
13355 creat("/etc/zdtm-test", 0600)     = -1 EACCES (Permission denied)

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-02-19 23:15:10 +03:00
Andrey Vagin
9b600167a5 zdtm: don't execute ns/ and ns/user tests simultaneously
One test can't be execute as ns/test ans ns/user/test
simultaneously, because they use the same file tree

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-02-19 23:14:59 +03:00
Saied Kazemi
1b4e9058e8 Do not call listen() when SO_REUSEADDR is off
For an established TCP connection, the send queue is restored in two
steps: in step (1), we retransmit the data that was sent before but not
yet acknowledged, and in step (2), we transmit the data that was never
sent outside before.  The TCP_REPAIR option is disabled before step (2)
and re-enabled after step (2) (without this patch).

If the amount of data to be sent in step (2) is large, the TCP_REPAIR
flag on the socket can remain off for some time (O(milliseconds)).  If a
listen() is called on another socket bound to the same port during this
time window, it fails. This is because -- turning TCP_REPAIR off clears
the SO_REUSEADDR flag on the socket.

This patch adds a mutex (reuseaddr_lock) per port number, so that a
listen() on a port number does not happen while SO_REUSEADDR for another
socket on the same port is off.

Thanks to Amey Deshpande <ameyd@google.com> for debugging.

Signed-off-by: Saied Kazemi <saied@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-02-16 13:18:32 +03:00