Skip to content
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

fixes for the SELinux policy #1236

Merged
merged 3 commits into from
Dec 15, 2020
Merged

Conversation

bcressey
Copy link
Contributor

@bcressey bcressey commented Dec 10, 2020

Issue number:
Fixes #1151

Description of changes:
Revise access rules for inotify, dnotify, and fanotify, as the policy previously blocked pods from collecting journal logs.

Adjust initial SIDs for network entities, as a preliminary step toward blocking network access from containers to the host.

Fix logic error in sets of subject types, which I uncovered while adding audit rules to log access to host sockets.

Testing done:
Ran the sonobuoy tests for the aws-k8s-1.18 variant (x86_64, aarch64). Test suite passed. Tested Cilium, Falco, EBS CSI driver, and the local storage provisioner on x86_64. Confirmed that the Cloudwatch Container Insights agent can collect journal logs. Ran a task for the aws-ecs-1 variant using the ECS CLI.

Verified in all cases that no new AVC denials were logged in dmesg or in the journal.

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.

We don't use any of the SELinux controls for network access, such as
packet or peer labeling. This sets permissive initial SIDs for these
entities to avoid unexpected restrictions.

Clean up the treatment of other initial SIDs at the same time. Many
of the unused ones have network-related names, and the fact that they
are treated differently can lead to confusion.

Signed-off-by: Ben Cressey <[email protected]>
The intent was for type attributes like "trusted_s" to only contain
subject types, but they were defined by negation and also included
all the object types. By using xor, we end up with the set members
we expect.

Since objects are not typically the actor in an SELinux access check,
this did not result in any additional permissions being granted, with
one exception: the ability to add a file to a filesystem is governed
by the "associate" action on the "filesystem" class, where the actor
is the file rather than the process.

Removing objects from the set of trusted users caused the system to
fail to boot, since files could no longer be created or relabeled.
To fix this, the "associate" action has been removed from the set of
"relabel" actions, and replaced with rules that permit the expected
behavior.

Signed-off-by: Ben Cressey <[email protected]>
These actions were originally restricted because fanotify can be used
to block access to files via permission events, which could disrupt
the operation of the host.

However, fanotify doesn't deliver events for accesses from outside
the mount namespace, so it's unlikely that containers depend on this
functionality.

Meanwhile, the restrictions on file and directory watches interfered
with containers that tried to monitor the journal file in order to
collect logs.

The updated policy allows broad use of inotify and dnotify watches,
while preventing access to fanotify's permission events.

Signed-off-by: Ben Cressey <[email protected]>
@bcressey bcressey merged commit eceed2b into bottlerocket-os:develop Dec 15, 2020
@bcressey bcressey deleted the policy-fixes branch December 15, 2020 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SELinux policy prevents pods from watching the journal
3 participants