Add missing type transitions for overlay-containers directories#446
Add missing type transitions for overlay-containers directories#446lsm5 merged 1 commit intocontainers:mainfrom
Conversation
Commit 6e2a14b added file context rules for overlay-containers, but did not add the corresponding type transition rules, causing these directories to be created with data_home_t instead of container_ro_file_t. This commit adds the missing filetrans_pattern rules for overlay-containers and overlay2-containers. Signed-off-by: Rolv Apneseth <[email protected]>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds SELinux file transition rules so overlay-containers and overlay2-containers directories under users’ container storage are automatically created with the correct container_ro_file_t type instead of data_home_t, complementing the previously-added file context rules. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary of ChangesHello, 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 a critical SELinux labeling bug affecting container storage directories. By introducing specific type transition rules, it ensures that Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe 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 by creating a comment using either
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 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
|
There was a problem hiding this comment.
Code Review
This pull request correctly adds the missing filetrans_pattern rules for overlay-containers and overlay2-containers to ensure they are created with the correct SELinux labels. This resolves an issue where these directories were being mislabeled. I've included one suggestion to improve the code's maintainability by sorting the related rules alphabetically.
| filetrans_pattern($1, data_home_t, container_ro_file_t, dir, "overlay") | ||
| filetrans_pattern($1, data_home_t, container_ro_file_t, dir, "overlay-images") | ||
| filetrans_pattern($1, data_home_t, container_ro_file_t, dir, "overlay-layers") | ||
| filetrans_pattern($1, data_home_t, container_ro_file_t, dir, "overlay-containers") | ||
| filetrans_pattern($1, data_home_t, container_ro_file_t, dir, "overlay2") | ||
| filetrans_pattern($1, data_home_t, container_ro_file_t, dir, "overlay2-images") | ||
| filetrans_pattern($1, data_home_t, container_ro_file_t, dir, "overlay2-layers") | ||
| filetrans_pattern($1, data_home_t, container_ro_file_t, dir, "overlay2-containers") |
There was a problem hiding this comment.
For better readability and long-term maintainability, it would be beneficial to keep these related filetrans_pattern rules sorted alphabetically by the directory name. This makes it easier to find specific rules and see what's covered at a glance.
filetrans_pattern($1, data_home_t, container_ro_file_t, dir, "overlay")
filetrans_pattern($1, data_home_t, container_ro_file_t, dir, "overlay-containers")
filetrans_pattern($1, data_home_t, container_ro_file_t, dir, "overlay-images")
filetrans_pattern($1, data_home_t, container_ro_file_t, dir, "overlay-layers")
filetrans_pattern($1, data_home_t, container_ro_file_t, dir, "overlay2")
filetrans_pattern($1, data_home_t, container_ro_file_t, dir, "overlay2-containers")
filetrans_pattern($1, data_home_t, container_ro_file_t, dir, "overlay2-images")
filetrans_pattern($1, data_home_t, container_ro_file_t, dir, "overlay2-layers")
lsm5
left a comment
There was a problem hiding this comment.
Thanks. LGTM
@containers/container-selinux-maintainers PTAL
|
@containers/container-selinux-maintainers let's get this in before #443 so it can be included in v2.247.0. |
|
@ca-hu PTAL |
I'm coming here from coreos/fedora-coreos-tracker#2095, as we're seeing failures in one of our tests due to the files in the
overlay-containersdirectory being marked for re-labelling. This was the output the author of the 6e2a14b shared:But in our test we're now seeing:
So, to my (very limited) understanding, their directory was created with the correct label because
artifactsis already covered by an existing rule, andrestoreconincorrectly wanted to relabel it. Then, in our case, the added context rules mean that everything underoverlay-containersis mislabelled andrestoreconcorrectly wants to relabel them. I believe I've been able to replicate this locally with a mix ofpodman pull alpineand manually creating directories, and this patch does seem to do the trick, but I do hope I'm not misunderstanding how this all works.In summary: commit 6e2a14b added file context rules for overlay-containers, but did not add the corresponding type transition rules, causing these directories to be created with
data_home_tinstead ofcontainer_ro_file_t. This PR adds the missingfiletrans_patternrules for overlay-containers and overlay2-containers so they're created with the correct labels.Summary by Sourcery
Bug Fixes: