I'm not sure if this is a limitation of mediation or a bug, but performing an 'ls -d /' is allowed after creating an overlayfs on merged, pivot_rooting to merged and chrooting to /.
Reproducer:
$ tar -zxvf ./overlay-with-pivotroot-ls-root.tar.gz && sudo ./overlay-with-pivotroot-ls-root/drv
overlay-with-pivotroot-ls-root/
overlay-with-pivotroot-ls-root/p.in
overlay-with-pivotroot-ls-root/overlay.c
overlay-with-pivotroot-ls-root/drv
overlay-with-pivotroot-ls-root/tst
Created tmpdir '/tmp/tmp.GBIqWfpROZ'
I'm not sure if this is a limitation of mediation or a bug, but performing an 'ls -d /' is allowed after creating an overlayfs on merged, pivot_rooting to merged and chrooting to /.
Reproducer: with-pivotroot- ls-root. tar.gz && sudo ./overlay- with-pivotroot- ls-root/ drv with-pivotroot- ls-root/ with-pivotroot- ls-root/ p.in with-pivotroot- ls-root/ overlay. c with-pivotroot- ls-root/ drv with-pivotroot- ls-root/ tst GBIqWfpROZ'
$ tar -zxvf ./overlay-
overlay-
overlay-
overlay-
overlay-
overlay-
Created tmpdir '/tmp/tmp.
Ubuntu 4.10.0- 26.30-generic 4.10.17
Disabling kernel rate-limiting printk_ ratelimit = 0
kernel.
Loading /tmp/tmp. GBIqWfpROZ/ data/p
chdir(/ tmp/tmp. GBIqWfpROZ/ data/mnt)
Creating the overlay directories GBIqWfpROZ/ data/mnt/ lower GBIqWfpROZ/ data/mnt/ upper GBIqWfpROZ/ data/mnt/ work GBIqWfpROZ/ data/mnt/ merged
- mkdir /tmp/tmp.
- mkdir /tmp/tmp.
- mkdir /tmp/tmp.
- mkdir /tmp/tmp.
Populating /tmp/tmp. GBIqWfpROZ/ data/mnt/ lower GBIqWfpROZ/ data/mnt/ lower/test- lower
- /tmp/tmp.
Populating /tmp/tmp. GBIqWfpROZ/ data/mnt/ upper GBIqWfpROZ/ data/mnt/ upper/test- upper
- /tmp/tmp.
Perform the overlay tmp/tmp. GBIqWfpROZ/ data/mnt/ upper tmp.GBIqWfpROZ/ data/mnt/ work tmp/tmp. GBIqWfpROZ/ data/mnt/ merged tmp.GBIqWfpROZ/ data/tst CLONE_NEWNS) /tmp/tmp. GBIqWfpROZ/ data/mnt/ merged' , '/tmp/tmp. GBIqWfpROZ/ data/mnt/ merged' , NULL, MS_BIND, NULL GBIqWfpROZ/ data/mnt/ merged' , NULL, MS_PRIVATE, NULL) GBIqWfpROZ/ data/mnt/ merged' , 'overlay', MS_MGC_VAL, lowerdir= /,upperdir= /tmp/tmp. GBIqWfpROZ/ data/mnt/ upper,workdir= /tmp/tmp. GBIqWfpROZ/ data/mnt/ work /tmp/tmp. GBIqWfpROZ/ data/mnt/ merged' ) GBIqWfpROZ/ data/tst'
lower=/
upper=/
work=/tmp/
where=/
exe=/tmp/
- unshare(
- success
- mount('
- success
- mount('none', '/tmp/tmp.
- success
- mount('overlay', '/tmp/tmp.
- success
- chdir('
- success
- pivot_root('.', '.')
- success
- chdir('/')
- success
chroot('.')
- success
starting '/tmp/tmp.
ls -ld / (EXFAIL)
- ls -ld /
drwxr-xr-x 1 root root 4096 Jul 12 15:56 /
FAIL: could ls -ld /
- ls / (EXFAIL)
ls: cannot open directory '/': Permission denied
- ls -lR / (EXFAIL)
ls: cannot open directory '/': Permission denied
Cleaning up GBIqWfpROZ/ data/mnt/ merged
- umount /tmp/tmp.
- rm -rf /tmp/tmp.GBIqWfpROZ