Repository navigation
Conversation
|
Needs a rebase when #1518 is merged |
|
Build action triggered: https://github.com/flatcar/scripts/actions/runs/7395050910 |
|
I've started a test run and when that passes I'll try again with flatcar/mantle#487 |
|
The |
|
We get a lot of denials - the image only works in permissive mode: |
|
I think that if we want to start labeling the whole filesystem, we should at least start enabling selinux USE flag globally and pull in the missing |
There was a problem hiding this comment.
🟡 Changes recommended
There are a couple of concrete correctness/consistency issues (notably setfiles path symlink handling in build_sysext, plus KEYWORDS consistency for riscv) that should be addressed before landing.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Updates the image build flow to generate SELinux policy earlier and apply file labeling to /usr and systemd-sysext contents, aiming to avoid previous Docker breakage while getting correct contexts into the immutable image artifacts.
Changes:
- Add
sec-policy/selinux-dockerto the base OS dependency set and portage-stable package list. - Split out
finish_image_common()to build SELinux policy before branching off the base squashfs, then extend labeling to/usrduringfinish_image. - Label sysext
/usrcontents directly inbuild_sysextafter the overlay unmount.
File summaries
| File | Description |
|---|---|
| sdk_container/src/third_party/portage-stable/sec-policy/selinux-docker/selinux-docker-9999.ebuild | New live ebuild for SELinux Docker policy. |
| sdk_container/src/third_party/portage-stable/sec-policy/selinux-docker/selinux-docker-2.20260616_p1.ebuild | New versioned ebuild for SELinux Docker policy. |
| sdk_container/src/third_party/portage-stable/sec-policy/selinux-docker/selinux-docker-2.20260312_p1.ebuild | New versioned ebuild for SELinux Docker policy. |
| sdk_container/src/third_party/portage-stable/sec-policy/selinux-docker/selinux-docker-2.20250618_p1.ebuild | New versioned ebuild for SELinux Docker policy. |
| sdk_container/src/third_party/portage-stable/sec-policy/selinux-docker/metadata.xml | Adds Gentoo SELinux team metadata for the new package. |
| sdk_container/src/third_party/portage-stable/sec-policy/selinux-docker/Manifest | Adds distfile entries required by the new policy package. |
| sdk_container/src/third_party/coreos-overlay/coreos-base/coreos/coreos-0.0.1.ebuild | Pulls selinux-docker policy into the base OS SELinux policy set. |
| build_sysext | Adds setfiles labeling for sysext /usr after overlay unmount. |
| build_library/prod_image_util.sh | Calls finish_image_common() prior to sysext branching in prod image builds. |
| build_library/dev_container_util.sh | Calls finish_image_common() prior to finish_image() in dev container builds. |
| build_library/build_image_util.sh | Introduces finish_image_common() and expands SELinux labeling to include /usr. |
| .github/workflows/portage-stable-packages-list | Ensures selinux-docker is included in the portage-stable package list. |
Review details
- Files reviewed: 12/12 changed files
- Comments generated: 6
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟡 Changes recommended
An active finding remains because the release-image change lacks the required user-facing changelog entry.
2 open issues
5 resolved since last review
This package’s KEYWORDS omit~riscv, unlike the othersec-policy/selinux-*ebuilds in this repo… This package’s KEYWORDS omit~riscv, unlike the othersec-policy/selinux-*ebuilds in this repo… This package’s KEYWORDS omit~riscv, unlike the othersec-policy/selinux-*ebuilds in this repo… This package’s KEYWORDS omit~riscv, unlike the othersec-policy/selinux-*ebuilds in this repo…finish_image_commondeclares a long list of positional parameters that are unused (only…
Review effort: Lite
| sec-policy/selinux-base-policy | ||
| sec-policy/selinux-container | ||
| sec-policy/selinux-dbus | ||
| sec-policy/selinux-docker |
So far we did not correctly label /usr because it broke certain things like Docker. With the sysext Docker and new policies we should try again. First generate the policy before branching off the base squashfs (which already misses a lot of things because they the most postprocessing is done late in finish_image!). Then label /usr and also the sysext contents in their folder - not in the overlay mount because this would operate on the whole image. Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
|
I rebased this following the gentoo merge and made some adjustments following feedback from Copilot. To be honest, so much has changed since Kai's version that I feel I should set myself as the author. I don't want him to be blamed for my bad work. 😅 And it is still bad because Kola couldn't even SSH to the nodes. |
|
The sysext files still have the wrong label, so I must have messed up there, but there appear to be far more issues beyond that. |
|
I've looked deeper into this. When I build the sysext on my own machine (Gentoo without SELinux), it gets labelled correctly. It appears to be an issue specific to the Jenkins worker. |



So far we did not correctly label /usr because it broke certain things like Docker. With the sysext Docker and new policies we should try again.
First generate the policy before branching off the base squashfs (which already misses a lot of things because they the most postprocessing is done late in finish_image!). Then label /usr and also the sysext contents in their folder - not in the overlay mount because this would operate on the whole image.
How to use
Hope that setfiles is clever enough
Verify with flatcar/mantle#487
Testing done
The sysext contents have the right label:
changelog/directory (user-facing change, bug fix, security fix, update)/bootand/usrsize, packages, list files for any missing binaries, kernel modules, config files, kernel modules, etc.