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

feat: add necessary SELinux allow rules #9127

Draft
wants to merge 42 commits into
base: main
Choose a base branch
from
Draft

Conversation

dsseng
Copy link
Member

@dsseng dsseng commented Aug 7, 2024

Pull Request

What? (description)

Make everything work with SELinux

Why? (reasoning)

Improve security, #8016

Acceptance

Please use the following checklist:

  • you linked an issue (if applicable)
  • you included tests (if applicable)
  • you ran conformance (make conformance)
  • you formatted your code (make fmt)
  • you linted your code (make lint)
  • you generated documentation (make docs)
  • you ran unit-tests (make unit-tests)

See make help for a description of the available targets.

Build SELinux policy without full generate step (might produce different results due to reliance on host tooling, but is faster):

secilc -o ./internal/pkg/selinux/policy/policy.33 -f ./internal/pkg/selinux/policy/file_contexts -c 33 ./internal/pkg/selinux/policy/selinux/**/*.cil -vvvvv -O

Read and analyze SELinux denials (make generate or alternative build required to match against the current policy):

talosctl --nodes 172.20.0.2 logs auditd > /tmp/audit.log && talosctl --nodes 172.20.0.3 logs auditd >> /tmp/audit.log && PYTHONPATH=/tmp/selinux/python/sepolgen/src python3 /tmp/selinux/python/audit2allow/audit2allow -C -p ./internal/pkg/selinux/policy/policy.33 -i /tmp/audit.log > /tmp/audit2allow.cil && PYTHONPATH=/tmp/selinux/python/sepolgen/src python3 /tmp/selinux/python/audit2allow/audit2allow -C -p ./internal/pkg/selinux/policy/policy.33 -e -i /tmp/audit.log > /tmp/audit2allow-explain.cil

Tip: to debug denials in QEMU:

secilc -c 33 selinux/**/*.cil -vvvvv && PYTHONPATH=/tmp/selinux/python/sepolgen/src python3 /tmp/selinux/python/audit2allow/audit2allow -i /tmp/tl-test-home/.talos/clusters/talos-default/talos-default-controlplane-1.log -C -p /tmp/talos/policy.33 > /tmp/audit2allow.cil && PYTHONPATH=/tmp/selinux/python/sepolgen/src python3 /tmp/selinux/python/audit2allow/audit2allow -i /tmp/tl-test-home/.talos/clusters/talos-default/talos-default-controlplane-1.log -C -p /tmp/talos/policy.33 -e > /tmp/audit2allow-explain.cil

@dsseng

This comment was marked as outdated.

@dsseng dsseng force-pushed the selinux branch 2 times, most recently from 75b4274 to 07a989f Compare October 28, 2024 18:39
@dsseng

This comment was marked as resolved.

@dsseng dsseng force-pushed the selinux branch 5 times, most recently from 13e9c1d to 9950176 Compare October 30, 2024 08:14
@dsseng dsseng force-pushed the selinux branch 7 times, most recently from 43dbed6 to 00d40bb Compare October 31, 2024 15:38
Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
requires kernel 6.8+ for userspace_initial_context capability

Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
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.

1 participant