Add container_runtime_nnp_domtrans interface for systemd-managed containers#473
Add container_runtime_nnp_domtrans interface for systemd-managed containers#473JJanasek wants to merge 1 commit into
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds a new SELinux interface to support domain transitions into the container runtime domain under NoNewPrivileges (NNP) and from nosuid mounts, primarily to enable systemd-managed Podman containers to run securely when NNP is enforced. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new interface container_runtime_nnp_domtrans in container.if to allow domain transitions to container_runtime_t under NoNewPrivileges (NNP) or nosuid. The reviewer suggests reusing the existing container_runtime_domtrans interface within the new interface to avoid duplicating the domain transition pattern and ensure all necessary permissions are inherited.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| interface(`container_runtime_nnp_domtrans',` | ||
| gen_require(` | ||
| type container_runtime_t, container_runtime_exec_t; | ||
| ') | ||
|
|
||
| domtrans_pattern($1, container_runtime_exec_t, container_runtime_t) | ||
| allow $1 container_runtime_t:process2 { nnp_transition nosuid_transition }; | ||
| ') No newline at end of file |
There was a problem hiding this comment.
Instead of duplicating the domain transition pattern, it is highly recommended to call the existing container_runtime_domtrans interface. This ensures that container_runtime_nnp_domtrans inherits all necessary permissions for executing the container runtime (such as corecmd_search_bin and FIFO file permissions) and simplifies future maintenance.
interface(`container_runtime_nnp_domtrans',`
gen_require(`
type container_runtime_t;
')
container_runtime_domtrans($1)
allow $1 container_runtime_t:process2 { nnp_transition nosuid_transition };
')
There was a problem hiding this comment.
AI is correct we already have a interface for this.
|
Tests failed. @containers/packit-build please check. |
Systemd services using standard hardening directives (such as DynamicUser, ProtectSystem, or RestrictSUIDSGID) automatically have NoNewPrivileges (NNP) enabled by systemd. When these services (e.g., Podman Quadlets) attempt to start containers, the kernel blocks the SELinux domain transition to container_runtime_t due to NNP or nosuid mount restrictions, causing the containers to fail at startup. This commit introduces the `container_runtime_nnp_domtrans` interface. It allows caller domains to explicitly bypass NNP and nosuid restrictions on the process2 class during the transition to the container runtime. This provides a clean way for base policies to enable secure, systemd-managed container workloads. Signed-off-by: jjanasek <jjanasek@redhat.com>
|
@JJanasek I don't think this PR is necessary, do you disagree? |
Description
This PR introduces a new interface,
container_runtime_nnp_domtrans, to allow caller domains to transition to the container runtime domain underNoNewPrivileges(NNP) and fromnosuidmounts.Why is this needed?
When running Podman containers via systemd (specifically using Podman Quadlets), administrators often use standard systemd security directives like
DynamicUser=yesorProtectSystem=strict. Systemd automatically enablesNoNewPrivileges=yeson the service process when these are used.Because of this, the kernel blocks the SELinux domain transition into
container_runtime_t, logging atclass=process2denial fornnp_transition(and oftennosuid_transition), causing the container to fail at startup.Currently, there is no interface exposed for caller domains to explicitly allow this transition under NNP.
What this PR does
It adds the
container_runtime_nnp_domtransinterface tocontainer.if.By exposing this interface, we allow other policies (like the base OS policy) to consume it without breaking encapsulation. I plan to submit a follow-up PR to
fedora-selinux/selinux-policythat uses this new interface to explicitly allowunconfined_service_tto spawn containers securely under NNP.Related Issues
https://bugzilla.redhat.com/show_bug.cgi?id=2417297
Summary by Sourcery
Introduce a new SELinux interface to support domain transitions into the container runtime under NoNewPrivileges and nosuid constraints.
New Features:
Enhancements: