Skip to content

aurora-sep: selinux: allow catacomb publication by atomic replacement - #2978

Open
mmdisbrow wants to merge 1 commit into
aurora-silicon:mainfrom
mmdisbrow:sep-selinux-1-14
Open

mmdisbrow wants to merge 1 commit into
aurora-silicon:mainfrom
mmdisbrow:sep-selinux-1-14

Conversation

@mmdisbrow

@mmdisbrow mmdisbrow commented Nov 23, 2026 •

Copy link
Copy Markdown

Why

Atomic catacomb replacement in #2966 writes each catacomb to /var/lib/.apple-sep-catacomb-{master,owner,user}.bin.new, resets its mode to 0600 when a caller's umask cleared bits, renames it over the target file, and unlinks any leftover temporary file. Under aurora-sep-selinux 1-13 (module 1.3.0), those temporary files inherit var_lib_t instead of aurora_sep_state_t and kernel_t lacks module-scoped setattr, rename, and unlink rules on aurora_sep_state_t. Per §1 review on #2966, split the SELinux policy update so aurora-sep-selinux 1-14 can land and ship ahead of the kernel consumer.

What changed

  • tools/aurora-sep/aurora_sep.te: bump module to 1.4.0, add setattr_file_perms rename_file_perms delete_file_perms to allow kernel_t aurora_sep_state_t:file, and add named type_transition rules for .apple-sep-catacomb-{master,owner,user}.bin.new.
  • tools/aurora-sep/aurora_sep.fc: add file-context pattern for /var/lib/\.apple-sep-catacomb-(master|owner|user)\.bin\.new.
  • tools/aurora-sep/packaging/fedora/aurora-sep.spec: bump Release to 1-14 with changelog entry.
  • tools/aurora-sep/tests/test_sep_selinux_state.py: verify the temporary file contexts, type_transition rules, and kernel_t allow rule without depending on drivers/soc/apple/store_shim.c.

Scope

SELinux policy, Fedora RPM spec, and policy unit tests only (drivers/ unchanged from 110861f43). Backwards-compatible with current truncate-in-place kernels.

Verification

  • Sparse checkout at 41a02cefc (Rust 1.85.0): all 16 Python test commands from sep-source.yml pass, including test_sep_selinux_state.py (14/14) and test_packaging.py (4/4).
  • checkpatch.pl reports 0 errors and 0 warnings; git diff --check is clean.
  • Throwaway registry.fedoraproject.org/fedora:45 (aarch64) container (selinux-policy-targeted-45.24-1.fc45, selinux-policy-devel-45.24-1.fc45, policycoreutils-3.11-2.fc45, setools-console-4.7.1-1.fc45):
    • tools/aurora-sep/packaging/fedora/build.sh compiled aurora_sep.pp with 0 errors and built aurora-sep-1-14.fc45.noarch.rpm, aurora-sep-selinux-1-14.fc45.noarch.rpm, and aurora-sep-1-14.fc45.src.rpm.
    • Offline semodule -s targeted -N -i upgrade from 1-13 (110861f43) to 1-14 (extracted from aurora-sep-selinux-1-14.fc45.noarch.rpm) succeeded cleanly into policy.35.
    • matchpathcon -f /etc/selinux/targeted/contexts/files/file_contexts moved /var/lib/.apple-sep-catacomb-{master,owner,user}.bin.new from system_u:object_r:var_lib_t:s0 (1-13) to system_u:object_r:aurora_sep_state_t:s0 (1-14), while keeping the canonical catacombs, aurora-sep-keybag.bin, and /dev/sep-bio unchanged.
    • sesearch on /etc/selinux/targeted/policy/policy.35 confirmed all 13 type_transition kernel_t var_lib_t:file aurora_sep_state_t rules (including the three .new names) and intact kernel_t/fprintd_t/kmod_t/init_t file rules.
  • Remaining before merge: maintainer CI workflow approval (SEP source checks and Host tests), and live Fedora SELinux Enforcing 1-13 to 1-14 upgrade check on a Touch ID Mac running the current kernel (0 SELinux denials, 0 failed units, 0 new kernel errors).

Assisted-by: OpenAI Codex (original change and cross-family review), Claude Code and Gemini (split, rework, and verification)

A kernel that publishes a catacomb by atomic replacement writes the
complete file under a fixed temporary name, ".<name>.new", in /var/lib,
and renames it over the catacomb. SELinux labels a file when it is
created and rename keeps that label, so the temporary must be created
with the state type, not var_lib_t.

Give the three temporary names aurora_sep_state_t with type_transition
rules and file contexts, and let the kernel set attributes on (to reset
a temporary's mode to 0600 after a restrictive caller umask), rename and
unlink state files. Bump the module to 1.4.0 and the package to 1-14.

This policy has to be installed before a kernel with atomic catacomb
replacement, so it lands and ships on its own first. It only adds
labels and permissions; current kernels are unaffected.

Signed-off-by: Matt <mmdisbro@gmail.com>

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Formal §1–§6 pre-PR checklist audit at live head 41a02cefcf581d3905149bd012353d73ee69fc12.

Splitting the SELinux policy precursor out of #2966 directly addresses the §1 chicken-and-egg upgrade-order blocker, and the policy rules themselves are well-aligned with #2966 (store_shim.c). However, CI has not run on this fork PR and §5 policy-build + Fedora SELinux Enforcing verification is still missing, so this cannot enter MERGETRAIN-LINUX4 yet.

Technical Audit (Cross-checked against #2966)

  • SELinux TE/FC rules (aurora_sep.te, aurora_sep.fc):
    • Bumps policy_module(aurora_sep, 1.4.0) cleanly.
    • Adds named type_transition kernel_t var_lib_t:file aurora_sep_state_t ".apple-sep-catacomb-{master,owner,user}.bin.new"; and matching .fc regex /var/lib/\.apple-sep-catacomb-(master|owner|user)\.bin\.new -- gen_context(system_u:object_r:aurora_sep_state_t,s0), matching store_shim.c's ".%s.new" names so renamed inodes preserve aurora_sep_state_t.
    • Adds valid refpolicy macros setattr_file_perms ({ setattr }), rename_file_perms ({ getattr rename }), and delete_file_perms ({ getattr unlink }) to allow kernel_t aurora_sep_state_t:file, matching notify_change(), vfs_rename(), and vfs_unlink() executed under override_creds(kern) in #2966.
    • Preserves the test_no_access_to_generic_var_lib invariant (no allow ... var_lib_t added).
  • Spec & backward compatibility (aurora-sep.spec, test_sep_selinux_state.py):
    • Cleanly bumps Release: 14%{?dist} with upgrade-order changelog note; strictly additive over 1-13 and backwards-compatible with current truncate-in-place kernels.
    • Unit tests verify .fc, type_transition, and allow rules without depending on store_shim.c.
    • (Non-blocking packaging note: fedora-aurora/packages/aurora-sep is currently ahead of linux/tools/aurora-sep at 1-22, so once this precursor lands, the same .te/.fc delta will need to be mirrored into the distribution package before shipping #2966.)

Blockers Before Approval

  1. CI not executed (action_required): Fork PR (mmdisbrow/aurora-silicon-linux) has empty statusCheckRollup; both SEP source checks (run 45183622208) and Host tests (run 45183621928) are action_required. Both workflows must be run and green on the final head before merge.
  2. §5 Policy build & Fedora SELinux Enforcing verification missing: test_sep_selinux_state.py only inspects .te/.fc text with regexes; it does not compile aurora_sep.pp via selinux-policy-devel (make -f /usr/share/selinux/devel/Makefile aurora_sep.pp) or verify module installation/upgrade. As noted in the PR body, live Fedora SELinux Enforcing build and upgrade testing are still pending. Before approval, please report:
    • Successful aurora_sep.pp compilation / RPM build with selinux-policy-devel.
    • Fedora SELinux Enforcing upgrade check (1-13 -> 1-14) on a Mac with SEP/Touch ID running the current kernel, confirming semodule installation, matchpathcon on /var/lib/.apple-sep-catacomb-{master,owner,user}.bin.new -> aurora_sep_state_t, no regressions on existing truncate-in-place SEP state, and the §5 regression tuple (0 SELinux denials, 0 failed units, 0 new kernel errors).

Checklist (§1–§6)

  • §1 No model gating / chicken-and-egg: Pass (clean precursor split ahead of #2966).
  • §2 Production-ready, no hacks: Pass.
  • §3 Safety: Conditional on §5 policy compilation and Enforcing upgrade verification.
  • §4 Clean-room & attribution: Pass — commit 41a02cefcf58 carries human author/committer (Matt <mmdisbro@gmail.com>) and human Signed-off-by: only, with zero AI trailers in commits; PR body includes Assisted-by:.
  • §5 Evidence: Blocked (see Blocker #2).
  • §6 Naming & CI: Naming Pass; CI Blocked (action_required, 0 checks run).

Assisted-by: LLM (Gemini 4 Neon)

@mmdisbrow

Copy link
Copy Markdown
Author

Added Fedora 45 (aarch64) container build and offline SELinux policy upgrade verification at 41a02cefc (against selinux-policy-targeted-45.24-1.fc45, selinux-policy-devel-45.24-1.fc45, policycoreutils-3.11-2.fc45, setools-console-4.7.1-1.fc45):

  1. build.sh / aurora_sep.pp compile: tools/aurora-sep/packaging/fedora/build.sh ran make -f /usr/share/selinux/devel/Makefile aurora_sep.pp with 0 errors and produced:
    • aurora-sep-1-14.fc45.noarch.rpm (66228 bytes)
    • aurora-sep-selinux-1-14.fc45.noarch.rpm (25498 bytes)
    • aurora-sep-1-14.fc45.src.rpm (91777 bytes)
  2. Offline 1-13 -> 1-14 semodule upgrade & matchpathcon:
    • Installing 1-13 (110861f43) via semodule -s targeted -N -i aurora_sep.pp left /var/lib/.apple-sep-catacomb-{master,owner,user}.bin.new labeled system_u:object_r:var_lib_t:s0.
    • Upgrading to aurora_sep.pp.bz2 extracted from aurora-sep-selinux-1-14.fc45.noarch.rpm succeeded cleanly (400 aurora_sep pp), and matchpathcon -f /etc/selinux/targeted/contexts/files/file_contexts resolved all three .new paths plus the canonical catacombs and aurora-sep-keybag.bin to system_u:object_r:aurora_sep_state_t:s0 (and /dev/sep-bio to system_u:object_r:aurora_sep_device_t:s0).
  3. Compiled binary policy (sesearch on /etc/selinux/targeted/policy/policy.35): All 13 type_transition kernel_t var_lib_t:file aurora_sep_state_t rules (including .apple-sep-catacomb-{master,owner,user}.bin.new) compiled into policy.35, with kernel_t, fprintd_t, kmod_t, and init_t access rules intact.

Remaining open blockers on this PR:

  • Maintainer approval to run SEP source checks and Host tests on 41a02cefc.
  • Live Fedora SELinux Enforcing 1-13 -> 1-14 upgrade check on a Touch ID Mac running the current kernel (0 SELinux denials, 0 failed units, 0 new kernel errors), which a container cannot cover.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants