-
Notifications
You must be signed in to change notification settings - Fork 519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
protect snapshot layers via SELinux policy #935
Merged
Merged
Conversation
This file contains 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
Signed-off-by: Ben Cressey <[email protected]>
This gives us a more accurate view of the daemon's status. Signed-off-by: Ben Cressey <[email protected]>
This integrates an upstream patch for containerd so the mount label will be used when the rootfs is mounted. Signed-off-by: Ben Cressey <[email protected]>
tjkirch
approved these changes
May 28, 2020
jamieand
approved these changes
May 29, 2020
Added a rule to cover Verified that an attempted write triggered a denial:
|
tjkirch
approved these changes
Jun 2, 2020
samuelkarp
reviewed
Jun 2, 2020
packages/containerd/2001-selinux-add-DefaultLabels-helper.patch
Outdated
Show resolved
Hide resolved
packages/containerd/2001-selinux-add-DefaultLabels-helper.patch
Outdated
Show resolved
Hide resolved
packages/containerd/2001-selinux-add-DefaultLabels-helper.patch
Outdated
Show resolved
Hide resolved
packages/containerd/2001-selinux-add-DefaultLabels-helper.patch
Outdated
Show resolved
Hide resolved
packages/containerd/2001-selinux-add-DefaultLabels-helper.patch
Outdated
Show resolved
Hide resolved
This ensures that we always end up with a mount label for the rootfs, which would otherwise not be writable. Signed-off-by: Ben Cressey <[email protected]>
Signed-off-by: Ben Cressey <[email protected]>
This integrates an upstream patch for containerd so the mount label will be used when the rootfs is mounted. Signed-off-by: Ben Cressey <[email protected]>
We expect the layers that make up containers to be labeled in a way that blocks writes from most processes. By applying a different label to the mount, we allow processes inside a running container to modify their own root filesystem, which would otherwise be immutable. Signed-off-by: Ben Cressey <[email protected]>
This causes Docker to apply SELinux labels to processes and mounts. Without the mount label, the root filesystem would not be writable. Signed-off-by: Ben Cressey <[email protected]>
Otherwise, the first mount attempt fails and logs this warning: Same superblock, different security settings for (dev mqueue, type mqueue) Signed-off-by: Ben Cressey <[email protected]>
Now that we have the machinery in place to provide a "context" option for overlayfs mounts, we can use a read-only type for file objects in the lower directories. We also record the type in `lxc_contexts` for programs that rely on that file for discovery. `host-ctr` now runs with the same type as the other container runtime components, because it handles the `mount()` syscall. The kernel will try to create a "work" subdirectory in workdir during the mount, so the calling process needs permissions to do so. Signed-off-by: Ben Cressey <[email protected]>
jamieand
approved these changes
Jun 4, 2020
samuelkarp
approved these changes
Jun 4, 2020
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.
Issue number:
#764
Description of changes:
Make
host-ctr
,docker
, andcontainerd
pass acontext=
option for overlayfs mounts, to allow writes to the upper layer that would be blocked by labels on the lower layers.Update the SELinux policy such that layers receive a different label when unpacked.
Fix a warning from
runc
by avoiding an incorrect attempt to mountmqueue
with a label that does not match the host.Testing done:
Tested
aws-dev
image locally andaws-k8s-1.15
image in EC2. Verified that conformance test passed. No AVC denials were logged. No SELinux warnings were logged for themqueue
mount.Confirmed via
mount
that host containers, Kubernetes pods, and Docker containers have thecontext
option specified.Confirmed that underlying directories have the
cache_t
label:Confirmed that files created inside the container end up with the
local_t
label:Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.