• Saied Kazemi's avatar
    Ignore mnt_id value for AUFS file descriptors. · e3fec5f8
    Saied Kazemi authored
    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: 's avatarSaied Kazemi <saied@google.com>
    Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
    e3fec5f8
Name
Last commit
Last update
Documentation Loading commit data...
arch Loading commit data...
contrib Loading commit data...
include Loading commit data...
lib Loading commit data...
pie Loading commit data...
protobuf Loading commit data...
pycriu Loading commit data...
scripts Loading commit data...
test Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
.travis.yml Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
Makefile Loading commit data...
Makefile.config Loading commit data...
Makefile.crtools Loading commit data...
Makefile.inc Loading commit data...
README Loading commit data...
action-scripts.c Loading commit data...
aio.c Loading commit data...
bfd.c Loading commit data...
cgroup.c Loading commit data...
cr-check.c Loading commit data...
cr-dedup.c Loading commit data...
cr-dump.c Loading commit data...
cr-errno.c Loading commit data...
cr-exec.c Loading commit data...
cr-restore.c Loading commit data...
cr-service.c Loading commit data...
cr-show.c Loading commit data...
crit Loading commit data...
crtools Loading commit data...
crtools.c Loading commit data...
eventfd.c Loading commit data...
eventpoll.c Loading commit data...
fifo.c Loading commit data...
file-ids.c Loading commit data...
file-lock.c Loading commit data...
files-ext.c Loading commit data...
files-reg.c Loading commit data...
files.c Loading commit data...
fsnotify.c Loading commit data...
image-desc.c Loading commit data...
image.c Loading commit data...
ipc_ns.c Loading commit data...
irmap.c Loading commit data...
kcmp-ids.c Loading commit data...
kerndat.c Loading commit data...
libnetlink.c Loading commit data...
log.c Loading commit data...
mem.c Loading commit data...
mount.c Loading commit data...
namespaces.c Loading commit data...
net.c Loading commit data...
netfilter.c Loading commit data...
page-pipe.c Loading commit data...
page-read.c Loading commit data...
page-xfer.c Loading commit data...
pagemap-cache.c Loading commit data...
parasite-syscall.c Loading commit data...
pipes.c Loading commit data...
plugin.c Loading commit data...
proc_parse.c Loading commit data...
protobuf-desc.c Loading commit data...
protobuf.c Loading commit data...
pstree.c Loading commit data...
ptrace.c Loading commit data...
rbtree.c Loading commit data...
rst-malloc.c Loading commit data...
sd-daemon.c Loading commit data...
sd-daemon.h Loading commit data...
security.c Loading commit data...
shmem.c Loading commit data...
sigframe.c Loading commit data...
signalfd.c Loading commit data...
sk-inet.c Loading commit data...
sk-netlink.c Loading commit data...
sk-packet.c Loading commit data...
sk-queue.c Loading commit data...
sk-tcp.c Loading commit data...
sk-unix.c Loading commit data...
sockets.c Loading commit data...
stats.c Loading commit data...
string.c Loading commit data...
sysctl.c Loading commit data...
sysfs_parse.c Loading commit data...
timerfd.c Loading commit data...
tty.c Loading commit data...
tun.c Loading commit data...
util.c Loading commit data...
uts_ns.c Loading commit data...