mount: don't close a namespace descriptor two times

CID null (#1 of 1): Double close (USE_AFTER_FREE)
10. double_close: Calling "restore_ns(int, struct ns_desc *)" closes
handle "ns_old" which has already been closed.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
check: Soft-dirty support is upstream since v3.11

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: increase the upstream kernel version

The kernel must be 3.11 or greater due to
29000cae ptrace: add ability to get/set signal-blocked mask (v2)

The patches for dumping tun devices are not committed in the upstream
kernel yet, so ns/static/tun is excluded.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
parasite: take into account the fact that a file descriptor can be zero

6. Condition "rst > 0", taking false branch
7. off_by_one: Testing whether handle "rst" is strictly greater than
   zero is suspicious. Did you intend to include equality with zero?
   "rst" leaks when it is zero.

CID 1072986 (#3 of 4): Resource leak (RESOURCE_LEAK)
12. leaked_handle: Handle variable "rst" going out of scope leaks the
handle.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
criu: Version 0.7 release

* Quite a lot of bugfixes and improvements in documentation, thanks to
feedback from users.

* New notable features include TUN devices, shared and master/slave
mounts and alternative signal stack (sigaltstack) support.

* Memory tracking is now upstream.

* This is the last release, that is tied to kernel release. The next
one will happen as soon as we decide it's worth doing so, not after
the linux-3.12.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
make: Extend rules macros to pick sources from variable

This will allow us to generate rules where source
for object file is laying in some extenal directory
but compiled one is to be kept in some other directory.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
make: Allow to compile sources from external directories

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
make: libcriu -- Use `obj-ext-src-y' target for pie/util-fd.c recompilation

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
doc: make -- Add description for `obj-ext-src-y'

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
tun: Use shorter name for ifr_name

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
make: Clean up build *.so if requested only

In OpenVZ -> CRIU converter I use same build engine
as in criu. But converter has own specifics such as
shipping precompiled vdso.so libraries. So when I
call for "make clean" these precompiled files get
automatically deleted, which in turn cause converter
to fail on next build attempt.

Thus lets delete only *.so targets which are declared
in makefiles.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Add more comments about shared files dump/restore

This is not trivial codeflow, let's document it till we
remember what and why it does.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
unix: Add comments about icons and external sockets

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
net: Sanitize dump_links() function code

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
util: remove unused the service fd constant

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
crtools: initial skeleton for cr_service

The criu service is a daemon, that opens a unix socket and listens for
incoming requests. The requests will be declared in protobuf/rpc.proto
and for now will only contain the 'dump' request.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
protobuf: Add rpc.proto file with messages description

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
crtools: Add cr_service meat

The need in service is described at http://criu.org/Self_dump

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
unix: Handle service socket on dump and restore

Service connection is actually an 'external' one from unix sockets engine POV,
but we don't want to dump it as such. Thus, we explicitly find one and dump it
as half-closed connection. On restore we push an artificial message into it
to report to the program that the dump-request was served, but the program is
restored.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Don't dump if children's uids are not equal to client's uid

This is for security -- service is run from root, but serves requests from non-root
processes. Thus, we shouldn't allow for anyone to dump suid programs that a run from
under unpriviledged processes.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>