Skip to content

fix(selinux): dontaudit bootc's mac_admin probe from plain services - #1279

Merged
hanthor merged 3 commits into
mainfrom
fix/selinux-dontaudit-bootc-probe
Nov 16, 2026
Merged

hanthor merged 3 commits into
mainfrom
fix/selinux-dontaudit-bootc-probe

Conversation

@hanthor

@hanthor hanthor commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

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 with semodule -n -i, just before utah-verify-desktop-contract. The module store is under read-only /usr once 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] modules section. The in-image verifier runs semodule -l and fails the build when a listed module isn't loaded, or when semodule is missing or can't list modules. --check validates the list's shape.
  • iso/scripts/luks-e2e.sh: on the installed system, the review VM now fails on any AVC denial whose comm is chcon or bootc. 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: the new docs/skills/desktop-contract/references/selinux-modules.md, plus pointers in desktop-contract.md, references/verifiers.md and local-testing.md.

Why

bootc status probes for mac_admin by running chcon with a label the policy doesn't define (bootc lsm.rs, selinux_ensure_install). Outside install_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_t AVCs 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's projectbluefin-countme, which runs bootc status --json as 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_admin denial in unconfined_service_t is hidden too. The kernel's SELINUX_ERR op=setxattr invalid_context=… record for the probe remains. It isn't an AVC, so neither gate counts it.

Verification

  • In the pinned Hummingbird base (os-minimal@sha256:a98c8cf5…, selinux-policy-targeted 45.24): before the module, sesearch finds neither an allow nor a dontaudit for unconfined_service_t self:capability2 mac_admin. After semodule -n -i utah_bootc_probe.cil, semodule -l lists utah_bootc_probe, sesearch --dontaudit shows dontaudit unconfined_service_t unconfined_service_t:capability2 mac_admin;, and no allow exists. In the same container, the verifier's missing_selinux_modules(["utah_bootc_probe"]) returns []; for a module that isn't loaded, it names that module.
  • tests/test_selinux_bootc_probe.py pins 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. SelinuxModuleTests in tests/test_desktop_contract_verify.py covers 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 at dfd7d5d (1383 tests OK, skill index and agent catalog current).
  • VM evidence comes from this PR's review-VM run: run 43803124504 (review_vm, contract_only): passed. The installed LUKS image still ships common's bootc-calling CountMe, and the new e2e step logged bootc 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 two mac_admin denials.

Closes #1198

@github-actions github-actions Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 16, 2026
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hanthor
hanthor force-pushed the fix/selinux-dontaudit-bootc-probe branch from 43f0c4a to dfd7d5d Compare November 16, 2026 04:16
@hivecommons-hive hivecommons-hive Bot added author/clanker A contributor's own hive authored this PR under their login no-dco A commit is missing Signed-off-by — run `git rebase --signoff` role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 16, 2026
Danathar
Danathar previously approved these changes Nov 16, 2026

@Danathar Danathar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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's dontaudit, not allow, 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 -i before utah-verify-desktop-contract (the store is read-only /usr once booted). The contract's new [selinux] modules makes the build fail if it isn't loaded.
  • The e2e check keeps failing on any chcon/bootc AVC, 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
hanthor enabled auto-merge (squash) November 16, 2026 05:08
@hanthor
hanthor disabled auto-merge November 16, 2026 05:26
@hanthor
hanthor enabled auto-merge (squash) November 16, 2026 05:35
@hanthor
hanthor disabled auto-merge November 16, 2026 05:57
@hanthor hanthor mentioned this pull request Nov 16, 2026
1 of 30 tasks
@hivecommons-hive

Copy link
Copy Markdown
Contributor

@hanthor this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Review asks:

  • the branch conflicts with the base and needs a rebase

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.

hanthor and others added 2 commits November 16, 2026 13:31
`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>
@hanthor
hanthor enabled auto-merge (squash) November 16, 2026 14:06
@hanthor
hanthor force-pushed the fix/selinux-dontaudit-bootc-probe branch from 0f06e11 to 450b0cd Compare November 16, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. author/clanker A contributor's own hive authored this PR under their login no-dco A commit is missing Signed-off-by — run `git rebase --signoff` role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

selinux: ublue-booted-image runs bootc status from a script, so bootc's capability probe logs two chcon AVC denials every boot

2 participants