-
Notifications
You must be signed in to change notification settings - Fork 106
container: label /run/user/*/crun as container_var_run_t #405
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
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR extends the SELinux policy to label the per‐user crun socket directory under /run/user/*/crun as container_var_run_t, ensuring proper confinement for crun’s control directory. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @giuseppe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request addresses an SELinux labeling discrepancy for container runtime files located in user-specific temporary directories. By adding a new policy rule, it ensures that these files are correctly labeled, which is crucial for maintaining the security and proper functioning of containerized applications.
Highlights
- SELinux Policy Update: Introduces a new SELinux rule to correctly label temporary files and directories within user-specific runtime paths (e.g., /run/user/*/crun) as container_var_run_t.
- Enhanced Container Security: Ensures that container runtime components like crun operating in user-specific environments have the appropriate security context, resolving potential access or permission issues.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: giuseppe, sourcery-ai[bot] The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request addresses an issue with rootless Podman on systems with SELinux enabled by updating the container SELinux policy. The change introduces a file transition rule using userdom_user_tmp_filetrans to ensure that files and directories created by the container runtime under /run/user/ are correctly labeled as container_var_run_t. This is a correct and targeted fix for the reported AVC denials. The implementation is clean and follows existing patterns in the policy file. I have no suggestions for improvement.
|
LGTM |
|
The closes doesn't link to #404 but the podman issue is that right? |
Closes: containers#404 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
ffb2f7c to
ae3532b
Compare
yeah that was wrong, thanks, fixed now.
I've tested the new policy and pasta seems to work fine with it: |
|
If you install this update from podman-next this update it is clearly broken now with pasta The podman tmt tests are failing now because of this https://artifacts.dev.testing-farm.io/2edbf35e-bee1-4913-b0ab-7cb340323048/ If this is the proper label then as I said we must coordinate this with a pasta policy update |
|
Oh and of course the title here is misleading since the commit didn't just chnage the label for |
|
@rhatdan this breaks things quite badly. Before we get a disproportionate amount of issues about pasta(1) not starting, can we revert this quick? By the way, @Luap99 also reported this before this was merged:
...but we clearly didn't have time, nor the indication, to change something in pasta's policy as a result. To prevent this kind of breakage in the future, can a test run perhaps be enforced as part of the integration process? Podman has a ton of tests executing quickly and reliably, and it looks like a shame not to use those. All related projects have some form of continuous integration testing, just not this one. In the pasta(1) test suite itself, we enforce running networking tests from Podman's HEAD. |
|
I send a patch to pasta to adapt the policy there https://archives.passt.top/passt-dev/20250917120450.36181-2-pholzing@redhat.com/
I think we run a subset of tests here via tmt but not sure if we run both root AND rootless here? And if the subset contains the right trigger since it requires the use of the custom network. |
|
Please open a PR to change it back. |
|
If this is only supposed to change the label on the crun directory, can we just do: Totally untested. |
|
that seems to work in my environment. @Luap99 I see you've prepared some patches for pasta as well, what version do you prefer? If we create all the files/dirs with |
Did you reboot? The tmpfiles are only created the first time around and then keep its context of course, so without a relabel this should only be noticeable after boot. And of course there is the issues of relabel rules can be different from transition rules.
Well frankly I have zero idea about what each label here is supposed to represent, with the amount of similar types here ( Logically having consistent behavior between root and rootless seems desirable so I am in favor of keeping this change and patch pasta's policy like I already posted. But that of course still needs to be coordinated, i.e. we cannot release this here until the pasta fix lands in fedora. |
|
But I guess container-selinux is still missing the file context rules for this change? I assume restorecon should work on these directories if we label container_var_run_t? |
|
have you tried deleting it completely and see how it gets recreated after you run Podman? |
|
Well I rebooted for my testing so yeah, and yes the dir is container_var_run_t due the transition rule here. The point is container_var_run_t is not compatible with the current pasta policy (hence my patches to pasta). But also because there is no default file context restorecon doesn't work for existing users that upgrade on a live system which seems unexpected? I assume selinux rules should always have file context rules for the files we are supposed to label. At the very least so that restorecon doesn't mess things up? But I guess that is not new, as root it seems to be broken as well. So here it is even worse because restorecon will apply the var_run_t label now? |
This reverts commit ae3532b ("container: label /run/user/*/crun as container_var_run_t") as it breaks basic Podman operation with pasta(1) (default rootless back-end): Error: setting up Pasta: pasta failed with exit code 1: Couldn't open PID file /run/user/1000/containers/networks/rootless-netns/rootless-netns-conn.pid: Permission denied A solution is being worked on, but it's not quite ready yet, see: containers#405 in the meantime, revert this to avoid widespread breakage for users. Link: containers#405 Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This reverts commit ae3532b ("container: label /run/user/*/crun as container_var_run_t") as it breaks basic Podman operation with pasta(1) (default rootless back-end): Error: setting up Pasta: pasta failed with exit code 1: Couldn't open PID file /run/user/1000/containers/networks/rootless-netns/rootless-netns-conn.pid: Permission denied A solution is being worked on, but it's not quite ready yet, see: containers#405 in the meantime, revert this to avoid widespread breakage for users. Link: containers#405 Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This reverts commit ae3532b ("container: label /run/user/*/crun as container_var_run_t") as it breaks basic Podman operation with pasta(1) (default rootless back-end): Error: setting up Pasta: pasta failed with exit code 1: Couldn't open PID file /run/user/1000/containers/networks/rootless-netns/rootless-netns-conn.pid: Permission denied A solution is being worked on, but it's not quite ready yet, see: #405 in the meantime, revert this to avoid widespread breakage for users. Link: #405 Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
In some cases the podman runroot directory used to be labelled container_var_run_t instead of user_tmp_t which was expected here. Starting with a recent container-selinux change the runroot is now always container_var_run_t so make the policy handle both types to allow for a better upgrade path where passt-selinux and container-selinux are not updated at the same time. Link: containers/container-selinux#405 Link: containers/podman#26473 Signed-off-by: Paul Holzinger <pholzing@redhat.com> [sbrivio: minor style edits] Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Closes: #404
Summary by Sourcery
Add SELinux policy to label /run/user/*/crun with container_var_run_t
Bug Fixes:
Enhancements: