Skip to content
This repository was archived by the owner on Jun 11, 2020. It is now read-only.

[17.06 backport] rootfs: umount all procfs and sysfs with --no-pivot #10

Conversation

thaJeztah
Copy link
Member

Backport of opencontainers#1962 for 17.06

cherry-pick was not clean, due to upstream having switched from syscall to unix. I resolved this by s/unix/syscall/.


When creating a new user namespace, the kernel doesn't allow to mount
a new procfs or sysfs file system if there is not already one instance
fully visible in the current mount namespace.

When using --no-pivot we were effectively inhibiting this protection
from the kernel, as /proc and /sys from the host are still present in
the container mount namespace.

A container without full access to /proc could then create a new user
namespace, and from there able to mount a fully visible /proc, bypassing
the limitations in the container.

A simple reproducer for this issue is:

unshare -mrfp sh -c "mount -t proc none /proc && echo c > /proc/sysrq-trigger"

Signed-off-by: Giuseppe Scrivano gscrivan@redhat.com
(cherry picked from commit 28a697c)
Signed-off-by: Sebastiaan van Stijn github@gone.nl

When creating a new user namespace, the kernel doesn't allow to mount
a new procfs or sysfs file system if there is not already one instance
fully visible in the current mount namespace.

When using --no-pivot we were effectively inhibiting this protection
from the kernel, as /proc and /sys from the host are still present in
the container mount namespace.

A container without full access to /proc could then create a new user
namespace, and from there able to mount a fully visible /proc, bypassing
the limitations in the container.

A simple reproducer for this issue is:

unshare -mrfp sh -c "mount -t proc none /proc && echo c > /proc/sysrq-trigger"

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
(cherry picked from commit 28a697c)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
Copy link
Member Author

thaJeztah commented Feb 14, 2019

ping @justincormack @kolyshkin @andrewhsu PTAL

@andrewhsu andrewhsu requested a review from justincormack March 28, 2019 15:44
andrewhsu pushed a commit that referenced this pull request Mar 28, 2019
This reverts commit fc48a25, reversing
changes made to 519d2ac.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@justincormack
Copy link

Note that syscall may not work for eg s390x in all cases, but this is unlikely to be an issue if it wasn't already.

@andrewhsu andrewhsu merged commit 728371c into docker-archive:17.06 Mar 28, 2019
@thaJeztah thaJeztah deleted the 17.06_backport_no_pivot_umount_proc_sys branch March 28, 2019 19:55
BSWANG pushed a commit to BSWANG/runc that referenced this pull request Jul 9, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants