2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-28 12:57:57 +00:00

8 Commits

Author SHA1 Message Date
Saied Kazemi
e3fec5f8eb Ignore mnt_id value for AUFS file descriptors.
Starting with version 3.15, the kernel provides a mnt_id field in
/proc/<pid>/fdinfo/<fd>.  However, the value provided by the kernel for
AUFS file descriptors obtained by opening a file in /proc/<pid>/map_files
is incorrect.

Below is an example for a Docker container running Nginx.  The mntid
program below mimics CRIU by opening a file in /proc/1/map_files and
using the descriptor to obtain its mnt_id.  As shown below, mnt_id is
set to 22 by the kernel but it does not exist in the mount namespace of
the container.  Therefore, CRIU fails with the error:

	"Unable to look up the 22 mount"

In the global namespace, 22 is the root of AUFS (/var/lib/docker/aufs).

This patch sets the mnt_id of these AUFS descriptors to -1, mimicing
pre-3.15 kernel behavior.

	$ docker ps
	CONTAINER ID        IMAGE                    ...
	3850a63ee857        nginx-streaming:latest   ...
	$ docker exec -it 38 bash -i
	root@3850a63ee857:/# ps -e
	  PID TTY          TIME CMD
	    1 ?        00:00:00 nginx
	    7 ?        00:00:00 nginx
	   31 ?        00:00:00 bash
	   46 ?        00:00:00 ps
	root@3850a63ee857:/# ./mntid 1
	open("/proc/1/map_files/400000-4b8000") = 3
	cat /proc/49/fdinfo/3
	pos:	0
	flags:	0100000
	mnt_id:	22
	root@3850a63ee857:/# awk '{print $1 " " $2}' /proc/1/mountinfo
	87 58
	103 87
	104 87
	105 104
	106 104
	107 104
	108 87
	109 87
	110 87
	111 87
	root@3850a63ee857:/# exit
	$ grep 22 /proc/self/mountinfo
	22 21 8:1 /var/lib/docker/aufs /var/lib/docker/aufs ...
	44 22 0:35 / /var/lib/docker/aufs/mnt/<ID> ...
	$

Signed-off-by: Saied Kazemi <saied@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-02-09 14:07:40 +03:00
Pavel Emelyanov
c864a31f05 Revert "Fix AUFS pathname handling when branch is not exposed"
This reverts commit 490ca718 to the 2749d9e6 fixes the problem
the other (proper) way.

Conflicts:
	sysfs_parse.c

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-22 15:03:59 +03:00
Saied Kazemi
2749d9e6ea Rework fixup_aufs_vma_fd() for non-AUFS links
This patch reworks fixup_aufs_vma_fd() to let symbolic links in
/proc/<pid>/map_files that are not pointing to AUFS branch names follow
the non-AUFS applcation logic.

The use case that prompted this commit was an application mapping
/dev/zero as shared and writeable which shows up in map_files as:

lrw------- ... 7fc5c5a5f000-7fc5c5a60000 -> /dev/zero (deleted)

If the AUFS support code reads the link, it will have to strip off the
" (deleted)" string added by the kernel but core CRIU code already
does this.

Signed-off-by: Saied Kazemi <saied@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-22 14:56:40 +03:00
Saied Kazemi
490ca71866 Fix AUFS pathname handling when branch is not exposed
The code that fixes up AUFS pathnames associated with vma entries (see
commit d8b41b6525) should handle cases where an entry does not expose
the branch pathname (e.g., pointing to a device like /dev/zero).

Signed-off-by: Saied Kazemi <saied@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-01-19 13:05:12 +03:00
Pavel Emelyanov
86c0c5fb99 proc: Allocate and get vma fstat in vma_get_mapfile
We will need to detect aio mappings soon, so this is a preparation,
that makes future patching simpler.

Also move aufs stat-ing into aufs code to keep more aufs logic in
one place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-25 21:10:15 +03:00
Andrey Vagin
c8d8cad179 sysfs: fix use_after_free issue
CID 73379 (#1 of 1): Use after free (USE_AFTER_FREE)
31. deref_arg: Calling fclose dereferences freed pointer fp.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-05 15:44:34 +04:00
Saied Kazemi
9eec8b03af Use --root instead of --aufs-root
When dumping Docker containers using the AUFS graph driver, we can
use the --root option instead of --aufs-root for specifying the
container's root.  This patch obviates the need for --aufs-root
and makes dump CLI more consistent with restore CLI.

Signed-off-by: Saied Kazemi <saied@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-27 14:31:40 +04:00
Saied Kazemi
d8b41b6525 Added AUFS support.
The AUFS support code handles the "bad" information that we get from
the kernel in /proc/<pid>/map_files and /proc/<pid>/mountinfo files.
For details see comments in sysfs_parse.c.

The main motivation for this work was dumping and restoring Docker
containers which by default use the AUFS graph driver.  For dump,
--aufs-root <container_root> should be added to the command line options.
For restore, there is no need for AUFS-specific command line options
but the container's AUFS filesystem should already be set up before
calling criu restore.

[ xemul: With AUFS files sometimes, in particular -- in case of a
  mapping of an executable file (likekely the one created at elf load),
  in the /proc/pid/map_files/xxx link target we see not the path
  by which the file is seen in AUFS, but the path by which AUFS
  accesses this file from one of its "branches". In order to fix
  the path we get the info about branches from sysfs and when we
  meet such a file, we cut the branch part of the path. ]

Signed-off-by: Saied Kazemi <saied@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-21 18:35:22 +04:00