rootfs: umount all procfs and sysfs with --no-pivot#1962
Merged
Conversation
Contributor
AkihiroSuda
reviewed
Jan 12, 2019
| return err | ||
| } | ||
| if err := unix.Unmount(p, unix.MNT_DETACH); err != nil { | ||
| if err.(syscall.Errno) != unix.EINVAL { |
Member
There was a problem hiding this comment.
Potentially we can also get EPERM here?
Member
Author
There was a problem hiding this comment.
I guess, but I never saw that error message, when trying to umount /proc or /sys I got only EINVAL. I can amend the patch if you'd like
Member
Author
There was a problem hiding this comment.
I went forward and amended the change in the updated version
5d8596f to
c18aa18
Compare
cyphar
reviewed
Jan 14, 2019
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>
c18aa18 to
28a697c
Compare
Contributor
AkihiroSuda
approved these changes
Jan 15, 2019
Member
AkihiroSuda
added a commit
to AkihiroSuda/docker
that referenced
this pull request
Jan 15, 2019
Changes: opencontainers/runc@96ec217...12f6a99 Including critical security fix for `runc run --no-pivot` (`DOCKER_RAMDISK=1`): opencontainers/runc#1962 Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
Closed
AkihiroSuda
added a commit
to AkihiroSuda/buildkit_poc
that referenced
this pull request
Jan 15, 2019
Including critical security fix for `runc run --no-pivot` (unlikely to affect BuildKit): opencontainers/runc#1962 Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
AkihiroSuda
added a commit
to AkihiroSuda/containerd
that referenced
this pull request
Jan 15, 2019
Changes: opencontainers/runc@96ec217...12f6a99 Including critical security fix for `runc run --no-pivot` (`DOCKER_RAMDISK=1`): opencontainers/runc#1962 Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
AkihiroSuda
added a commit
to AkihiroSuda/containerd
that referenced
this pull request
Jan 15, 2019
Changes: opencontainers/runc@96ec217...12f6a99 Including critical security fix for `runc run --no-pivot` (`DOCKER_RAMDISK=1`): opencontainers/runc#1962 Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp> (cherry picked from commit 3aec9e7)
AkihiroSuda
added a commit
to AkihiroSuda/docker
that referenced
this pull request
Jan 15, 2019
Changes: opencontainers/runc@96ec217...12f6a99 Including critical security fix for `runc run --no-pivot` (`DOCKER_RAMDISK=1`): opencontainers/runc#1962 Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp> (cherry picked from commit 1ee33f4)
AkihiroSuda
added a commit
to AkihiroSuda/containerd
that referenced
this pull request
Jan 15, 2019
Changes: opencontainers/runc@96ec217...12f6a99 Including critical security fix for `runc run --no-pivot` (`DOCKER_RAMDISK=1`): opencontainers/runc#1962 Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp> (cherry picked from commit 3aec9e7) Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
AkihiroSuda
added a commit
to AkihiroSuda/docker
that referenced
this pull request
Jan 15, 2019
Changes: opencontainers/runc@69663f0...12f6a99 Including critical security fix for `runc run --no-pivot` (`DOCKER_RAMDISK=1`): opencontainers/runc#1962 Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
tstromberg
added a commit
to tstromberg/minikube
that referenced
this pull request
Jan 16, 2019
robertgzr
pushed a commit
to balena-os/balena-containerd
that referenced
this pull request
Mar 4, 2019
Changes: opencontainers/runc@96ec217...12f6a99 Including critical security fix for `runc run --no-pivot` (`DOCKER_RAMDISK=1`): opencontainers/runc#1962 Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
kolyshkin
reviewed
Mar 13, 2020
| return err | ||
| } | ||
|
|
||
| absRootfs, err := filepath.Abs(rootfs) |
Contributor
There was a problem hiding this comment.
AFAICS this is not needed since rootfs is already validated by (*ConfigValidator).rootfs()
kolyshkin
reviewed
Mar 13, 2020
| } | ||
|
|
||
| for _, info := range mountinfos { | ||
| p, err := filepath.Abs(info.Mountpoint) |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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