Repository navigation
fix(selinux): stop two harmless security warnings on every boot - #1203
kylerankin wants to merge 2 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Needs approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/ok-to-test |
|
Cannot /ok-to-test because Error: hivecommons-hive[bot] is not a reviewer or approver for any changed file |
Danathar
left a comment
There was a problem hiding this comment.
Thanks for tracking down the AVC source; running bootc status as the bare ExecStart is the right idea. Two problems with how the output is captured, though. Both reproduce on systemd 259 with a transient unit.
1. ExecStartPost truncates the JSON before the sync script reads it.
StandardOutput= applies to every process the unit runs, not just ExecStart. Each command opens truncate:/run/ublue-os/booted-image.json again when it starts, so by the time ublue-booted-image-sync runs, the file is empty. jq finds no ref, and the script exits 0 with "no booted bootc image found", so /run/ublue-os/booted-image is never written.
Repro: systemd-run --user --wait -p Type=oneshot -p StandardOutput=truncate:/var/tmp/t/out.json -p "ExecStartPost=/bin/sh -c 'wc -c < /var/tmp/t/out.json > /var/tmp/t/post.txt'" /bin/echo '{"hello":"world"}'. post.txt says 0, and out.json ends at 0 bytes.
2. ExecStartPre can't create the directory its own stdout needs.
For the same reason, systemd opens /run/ublue-os/booted-image.json for the install -d command too, before it runs. If /run/ublue-os doesn't exist, that open fails and the unit fails. Nothing in utah creates /run/ublue-os earlier in boot; today only the sync script does. Repro: same command with -p "ExecStartPre=/usr/bin/install -d …/newdir" and stdout pointed into newdir. Result: Finished with result: exit-code, and newdir is never created.
The new unit test passes because it checks the unit file's shape, not what systemd does with it.
Suggested shape:
- Create the directory before the unit runs, with a tmpfiles.d entry (
d /run/ublue-os 0755 root root -), and drop theExecStartPre. - Keep
ublue-booted-image.serviceas onlyExecStart=/usr/bin/bootc status --jsonplusStandardOutput=truncate:…json. - Move the parse step into its own oneshot unit that has no
StandardOutputoverride. For example,ublue-booted-image-sync.servicewithRequires=/After=ublue-booted-image.service, the sameBefore=systemd-user-sessions.service, andExecStart=/usr/bin/ublue-booted-image-sync /run/ublue-os/booted-image.json. - Add a test that fails when a unit with
StandardOutput=file:/truncate:also hasExecStartPre=/ExecStartPost=. - If possible, show
/run/ublue-os/booted-imagepopulated on a booted image (the acceptance line in the description).
#1201 and #1203 have identical diffs, so I'm closing #1201 as a duplicate. Please carry on in #1203.
|
@kylerankin this PR is back in your court ( Review asks:
Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path. Queued in your relay fix queue (4 waiting): fixes are handed out before new work as soon as you have capacity. |
|
@kylerankin the hive has adopted this PR ( |
|
The hive adopted this PR ( Blocker: lane reason Moving to |
ublue-booted-image.service recorded the booted image ref by running `bootc status --json` from the ublue-booted-image-sync script. bootc then ran in the script's unconfined service domain instead of its own SELinux domain, so its relabelling chcon probe was denied mac_admin, logging two AVC denials in every boot. Run bootc as the unit's bare ExecStart so it enters bootc's install_exec_t domain, truncate its JSON to a file, and parse that file in ExecStartPost with the existing sync script. /run/ublue-os/booted-image still holds the same reference for fastfetch. Hive-Run: projectbluefin#1198 Hive-Plan: selinux-booted-image-avc-denials Hive-Spec: projectbluefin#1198 Signed-off-by: kylerankin <kylerankin@users.noreply.github.com>
c8d1ae8 to
851bff0
Compare
|
hive-base-moved: base rebased onto 5c2986e (testing tip). behind_by is now 0; branch is clean and mergeable. Continuing to review comments. 🐝 Hive Agent: |
|
@kylerankin this PR has a new head without confirmed hive push evidence, so the hive has handed this PR back to you ( |
…1203) ublue-booted-image.service recorded the booted bootc image by truncating `bootc status --json` to a file and parsing it in ExecStartPost. That broke two ways on systemd 259: StandardOutput=truncate: applies to every Exec* of the unit, so the ExecStartPost parse step opened the same path and truncated it to empty before the script read it, and the ExecStartPre that created /run/ublue-os also opened the stdout file before the directory existed. Move the parse into a new ublue-booted-image-sync.service unit that has no StandardOutput override, keyed Requires=/After= the bootc unit. Create /run/ublue-os early with a tmpfiles.d rule instead of ExecStartPre, so it exists before bootc's StandardOutput truncates its JSON there. A test now fails if any unit truncates stdout while also running ExecStartPre/Post. Hive-Run: projectbluefin#1203 Hive-Plan: selinux-booted-image-avc-denials-2 Hive-Spec: projectbluefin#1203 Signed-off-by: kylerankin <kylerankin@users.noreply.github.com>
|
Addressed on the new head (85d5615). Both bugs were real
Tests ( The remaining acceptance line — show 🐝 Hive Agent: |
|
@kylerankin the hive has adopted this PR ( |
|
The hive adopted this PR ( Blocker: lane reason Moving to |
Danathar
left a comment
There was a problem hiding this comment.
Stand-in re-review at 85d5615 (the hive's reviewers are out of quota). The two-unit split fixes the truncate bugs from my last review. But test-VM runs show this approach doesn't stop the #1198 denials, so it can't close that issue.
Evidence: #1220 tried the same design at 0db1983: ublue-booted-image.service with ExecStart=/usr/bin/bootc status --json and the parse in a second unit. Its review-VM run 43600763520 still logged both denials: { mac_admin } for pid=… comm="chcon" capability=33 scontext=system_u:system_r:unconfined_service_t. Running bootc as a unit's bare ExecStart doesn't move it into another domain. Then a3fe39d removed bootc from boot units entirely, and run 43605406732 logged the same two denials anyway. So #1198's attribution to this unit, which was by timing, looks wrong. Something else runs that chcon, and #1220 is now adding diagnostics (iso/scripts/avc-origin.sh) to find it.
Also: ExecStart=/usr/bin/bootc status --json has no - prefix. A bootc failure would now fail the unit and, through Requires=, skip ublue-booted-image-sync.service, which the old || true script never did.
Suggestion: park this until #1220's diagnostics name the real source. If the boot unit turns out not to be involved, this PR isn't needed. That's Doug's call as maintainer.
|
The hive adopted this PR ( Blocker: lane reason Moving to |
|
Closing in favour of #1279. Owner decision (2026-11-16, delegated). Thanks, @kylerankin. This PR's two-unit split, and the truncate-on-reopen analysis behind it, was the right way to run bootc as a bare #1279 handles #1198 at the policy level instead: a build-time module, |
Summary: Every time Utah starts, a small service that records which version of Utah is running makes the tool that updates Utah run in the wrong security context. That writes two harmless "denied" warnings to the security log on every boot. Nothing breaks, but those warnings are alarming to see, and now that Utah's automated tests read that log, they would fail every test run. This change runs the update tool the way Utah already runs it elsewhere — as the service's own startup command instead of from inside a helper script — so it gets the correct security context and the warnings stop, while still recording the same image for fastfetch to show.
What I need from you: Approve it.
What changed
ExecStart), so the tool runs in its own SELinux domain instead of inside the helper script's broad, unrestricted domain.Why
ghcr.io/projectbluefin/utah:testingfailed its SELinux gate on exactly these two records — twochconcalls deniedmac_admin, 134 ms apart, about 12.7 s into boot, fromublue-booted-image.service.Acceptance
chcon"denied" entries in the boot log or audit log of a booted:testingbuild./run/ublue-os/booted-imagestill holds the same referencebootc statusreports, so fastfetch shows the right image.Tests
tests/test_booted_image_unit.py) that pins the service's shape: the update tool runs directly asExecStart, its output is truncated to a file, a startup step makes the folder first, the helper script reads that file, and the helper script no longer runs the tool itself. All 5 cases pass.Note for a maintainer
manual.ymlwithsuites=commonon this PR's built image (testsuite fix(tuned): keep TuneD off the bootc sysroot lock #1171, or themainbranch) and link the run so the AVC gate is confirmed green.Closes #1198
— hive: backend=pi model=lemonade/ornith-1.5-35b-a3b-gguf-q6_k