Repository navigation
fix(selinux): dontaudit bootc's mac_admin probe from plain services - #1279
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hanthor 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 |
43f0c4a to
dfd7d5d
Compare
Danathar
left a comment
There was a problem hiding this comment.
Stand-in review (the hive's reviewers are out of quota). Approving. This fixes #1198 at the policy level instead of chasing each caller, and that's the right call.
Why this beats the caller-side fix alone: the CountMe-masked VM run (43762243257) proved CountMe was today's source, and projectbluefin/common#1689 stops CountMe calling bootc. But any plain service that runs bootc trips the same probe. After #1251, uupd.service runs bootc from unconfined_service_t too, so a caller-side fix would keep reopening this. common#1689 is still worth landing, since a ping doesn't need bootc, but this PR is what closes #1198.
Checked:
- The module is exactly one rule:
(dontaudit unconfined_service_t self (capability2 (mac_admin))). It'sdontaudit, notallow, so bootc's probe still gets "denied" and behaves as before. A capability has no target object, so one source domain plus one permission is the narrowest rule SELinux can express. - It's loaded at build time with
semodule -n -ibeforeutah-verify-desktop-contract(the store is read-only/usronce booted). The contract's new[selinux] modulesmakes the build fail if it isn't loaded. - The e2e check keeps failing on any
chcon/bootcAVC, so a regression still shows.
Trade-off, worth keeping in mind: any other mac_admin denial from unconfined_service_t is now hidden from the AVC log and the testsuite gate, as the PR says. The SELINUX_ERR … invalid_context record still appears, which helps.
The review-VM run (43803124504) is the proof. It should report bootc chcon AVC denials: none with CountMe still calling bootc.
|
@hanthor 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 (8 waiting): fixes are handed out before new work as soon as you have capacity. |
`bootc status` probes for mac_admin by running chcon with a label the policy does not define. From a plain service (common's projectbluefin-countme runs `bootc status --json` as root) the probe is denied in unconfined_service_t, and every boot logs two AVC denials that fail the testsuite's SELinux gate. bootc expects the denial and carries on, so the fix is a policy module with one dontaudit rule, not an allow: an allow would let every unconfined service write labels the policy does not know and would change what the probe decides. The module store is on read-only /usr once booted (#551), so the desktop RUN step loads utah_bootc_probe.cil with `semodule -n -i`. A new [selinux] section in the desktop contract makes the in-image verifier check `semodule -l` and fail the build if the module is missing. The installed-system e2e (review VM) now fails on any chcon/bootc AVC denial, the check #1220 introduced. Closes #1198 Assisted-by: Claude Opus via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assisted-by: Claude Opus via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0f06e11 to
450b0cd
Compare
What changed
system_files/shared/usr/share/selinux/packages/utah/utah_bootc_probe.cil: a policy module with one rule:(dontaudit unconfined_service_t self (capability2 (mac_admin))).Containerfile: the desktop RUN step loads it withsemodule -n -i, just beforeutah-verify-desktop-contract. The module store is under read-only/usronce booted (store-root=/usr/lib/selinux, SELinux: setsebool -P, semanage and semodule cannot work on Utah (policy store is on read-only /usr) #551), so the build is the only place it can be loaded.contracts/bluefin-desktop.toml/scripts/verify-desktop-contract.py: a new[selinux] modulessection. The in-image verifier runssemodule -land fails the build when a listed module isn't loaded, or when semodule is missing or can't list modules.--checkvalidates the list's shape.iso/scripts/luks-e2e.sh: on the installed system, the review VM now fails on any AVC denial whosecommischconorbootc. This is fix(selinux): run bootc as the booted-image unit's ExecStart; parse in a second unit #1220's check, without its booted-image part.docs/skills/desktop-contract/references/selinux-modules.md, plus pointers indesktop-contract.md,references/verifiers.mdandlocal-testing.md.Why
bootc statusprobes formac_adminby runningchconwith a label the policy doesn't define (bootclsm.rs,selinux_ensure_install). Outsideinstall_t, the probe is denied. bootc re-executes once, probes again, and carries on. When bootc runs from a plain service, that's two{ mac_admin } capability=33 scontext=…unconfined_service_tAVCs every boot, and they fail the testsuite's SELinux gate.#1203 and #1220 tried running bootc as a unit's bare
ExecStart. Run 43600763520 showed the denials persist. #1220's diagnostics, and the CountMe-masked run 43762243257 (#1247), traced the boot-time source to common'sprojectbluefin-countme, which runsbootc status --jsonas root. common#1689 (held) stops CountMe from calling bootc. This module silences the probe for any plain service that runs bootc, including CountMe, scripts and users' own units, without waiting on common.dontaudit, not allow. bootc works without the capability: it treats the denial as the answer. An allow would let every unconfined service write labels the policy doesn't know, and would change what the probe decides. A capability check has no target object except the process itself, so one domain plus one permission is the narrowest rule SELinux can express. The trade-off: any other
mac_admindenial inunconfined_service_tis hidden too. The kernel'sSELINUX_ERR op=setxattr invalid_context=…record for the probe remains. It isn't an AVC, so neither gate counts it.Verification
os-minimal@sha256:a98c8cf5…, selinux-policy-targeted 45.24): before the module,sesearchfinds neither an allow nor a dontaudit forunconfined_service_t self:capability2 mac_admin. Aftersemodule -n -i utah_bootc_probe.cil,semodule -llistsutah_bootc_probe,sesearch --dontauditshowsdontaudit unconfined_service_t unconfined_service_t:capability2 mac_admin;, and no allow exists. In the same container, the verifier'smissing_selinux_modules(["utah_bootc_probe"])returns[]; for a module that isn't loaded, it names that module.tests/test_selinux_bootc_probe.pypins the module to the single rule, checks that the build loads it in the same RUN step before the contract check, and checks that the contract lists it.SelinuxModuleTestsintests/test_desktop_contract_verify.pycovers the verifier: a loaded module passes and is counted; a missing module, a failing semodule or a missing semodule fails; malformed lists are rejected.just check: passes locally atdfd7d5d(1383 tests OK, skill index and agent catalog current).review_vm,contract_only): passed. The installed LUKS image still ships common's bootc-calling CountMe, and the new e2e step loggedbootc chcon AVC denials: none. The same check on fix(selinux): run bootc as the booted-image unit's ExecStart; parse in a second unit #1220's image without the module found twomac_admindenials.Closes #1198