The root cause of this fail is a wrong mount ID which is reported for file mappings:
Steps to reproduce:
root@ubuntu-s-4vcpu-8gb-nyc1-01:~# uname -a
Linux ubuntu-s-4vcpu-8gb-nyc1-01 5.3.0-26-generic #28-Ubuntu SMP Wed Dec 18 05:37:46 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
root@ubuntu-s-4vcpu-8gb-nyc1-01:~# docker run -it --rm --privileged busybox
/ # ls -l /proc/1/map_files/
total 0
lr-------- 1 root root 64 Jan 7 18:59 400000-401000 -> /bin/sh
lr-------- 1 root root 64 Jan 7 19:00 401000-4dd000 -> /bin/sh
lr-------- 1 root root 64 Jan 7 19:00 4dd000-514000 -> /bin/sh
lr-------- 1 root root 64 Jan 7 19:00 514000-516000 -> /bin/sh
The root cause of this fail is a wrong mount ID which is reported for file mappings:
Steps to reproduce:
root@ubuntu- s-4vcpu- 8gb-nyc1- 01:~# uname -a s-4vcpu- 8gb-nyc1- 01 5.3.0-26-generic #28-Ubuntu SMP Wed Dec 18 05:37:46 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Linux ubuntu-
root@ubuntu- s-4vcpu- 8gb-nyc1- 01:~# docker run -it --rm --privileged busybox
/ # ls -l /proc/1/map_files/
total 0
lr-------- 1 root root 64 Jan 7 18:59 400000-401000 -> /bin/sh
lr-------- 1 root root 64 Jan 7 19:00 401000-4dd000 -> /bin/sh
lr-------- 1 root root 64 Jan 7 19:00 4dd000-514000 -> /bin/sh
lr-------- 1 root root 64 Jan 7 19:00 514000-516000 -> /bin/sh
/ # exec 50</proc/ 1/map_files/ 400000- 401000 fdinfo/ 50 mountinfo | grep 551
/ # cat /proc/self/
pos: 0
flags: 0100000
mnt_id: 551
/ # cat /proc/self/
We can see that the mount 551 isn't listed in container mounts.
If we will try to open /bin/sh directly, we will see the mount ID of the container root mount.
/ # exec 50</bin/sh fdinfo/ 50 mountinfo | grep '^607' /var/lib/ docker/ overlay2/ l/DCAEKRDYRDTVU IECWWPMTFAKAO: /var/lib/ docker/ overlay2/ l/BEYAU2IKCGHGS 5UYC7C6Q6HIHG, upperdir= /var/lib/ docker/ overlay2/ 1c92eec684804fb c8642a9a4698a00 99c9ff5c3991528 9e1fcd1b3949355 8c65/diff, workdir= /var/lib/ docker/ overlay2/ 1c92eec684804fb c8642a9a4698a00 99c9ff5c3991528 9e1fcd1b3949355 8c65/work, xino=off
/ # cat /proc/self/
pos: 0
flags: 0100000
mnt_id: 607
/ # cat /proc/self/
607 567 0:51 / / rw,relatime master:308 - overlay overlay rw,lowerdir=