Skip to content

soc: apple: sep: let a second Linux install create its Touch ID keybag on M2 Pro/Max - #856

Merged
DjDeveloperr merged 1 commit into
integration/aurorafrom
sep/keybag-create-xart-window
Nov 2, 2026
Merged

DjDeveloperr merged 1 commit into
integration/aurorafrom
sep/keybag-create-xart-window

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

A fresh Aurora Fedora install on a MacBook Pro M2 Pro (Mac14,9, J414s, T6020) never brought up the SEP. aurora-sep.service timed out after 120 s, fprintd never started, and trusted keys failed with EEXIST. The same Mac already has an Arch Linux ARM install whose Touch ID works. This lets the second install create its own keybag, and lets an install that this already broke recover by itself.

What happened

Kernel 7.3.0-11.fc44.aurora (aurora-wip 52f0a6b), first boot of the new install:

xART guard level 1: 9 session records exist, 0 created by Linux; the other 9 are protected
xART: APFS-resolved .gl extent (base 0x4d4000); 170 slots, 11 live records, max revision 1196, ...
created a new host-state store
xART guard: refused to rewrite kind-4 record 423ea61c9d9bea910c6fe518fe9a6179, which this Linux install did not create
sks: CREATE_KEYBAG got no reply after 2044 ms
bringup: identity-keybag provisioning failed; no retry this boot
trusted-keys: seal failed (EEXIST); the machine ref-key may not be established yet
hwrng: survey failed after 5 attempts (ETIMEDOUT)

CREATE_KEYBAG (sks_provision_identity_keybag in sks.rs) makes the enclave rewrite one existing kind-4 record. The guard refused it (Guard::check in xart_guard.rs), and the enclave did not fail the create. It stopped answering, so the hardware RNG and every later key-store request timed out for the rest of the boot. The guard list stayed empty, so the enclave wrote no new session record, and the only record that changed was the shared kind-2 root (revision 1196 to 1197).

The driver writes a create intent before it sends CREATE_KEYBAG and keeps it when no answer comes, because a bag might exist that nothing names (keybag::read returns EEXIST for an intent). On the next boot (7.3.0-12, e1524e6) the SEP itself was healthy, with no refusal and the hardware RNG registered. But the driver would not create a keybag again:

sks: identity keybag state is ambiguous: EEXIST
bringup: identity-keybag provisioning failed; no retry this boot

So this install stays broken on every later boot, whatever kernel it updates to.

Which record, and whose

Record 423ea61c is not the other Linux install's record. It is shared enclave state:

  • ALARM's own raw SEP capture from 2026-09-26 has it among the four kind-4 records the enclave reads at every attach. It was 1654 bytes then and is 4020 bytes now.
  • It was last written at revision 1192. ALARM's last boot, today at 02:13, saw a highest revision of 1014. Fedora's first driver load at 06:04 saw 1196. In between, neither Linux install was running and 182 revisions were written, by macOS or recoveryOS while the new install was set up.
  • ALARM's own Touch ID state is a set of files on ALARM's partition: a committed keybag, ref-key, catacombs and fprintd prints. Since 2026-10-21 it has run under the guard with an empty list, and its journal shows "restored 2 enrolled identities" on every boot, with no refusal.

Why the old strictness was wrong here

The guard protects records that exist when the driver opens the gigalocker and that are not on Linux's list. This record predates every Linux install on the Mac, so it is never on the list, and every guarded keybag creation on this Mac asks to rewrite it. Having another Linux install is not what triggers it. ALARM only has a keybag because it made it on 2026-09-17, before the guard existed. XART-SAFETY.md listed guarded creation on M2 Pro/Max as untested, and this is the first measurement.

Refusing the write did not keep the record safe from a confused driver. The enclave itself asks for the write, as macOS's enclave did this morning. The refusal left the enclave stuck mid-create and left Linux without a keybag for good.

The change

Keybag creation window (xart_guard.rs, sks.rs, xart_store.rs)

  • On every guarded Mac, the identity CREATE_KEYBAG exchange runs in the same window a boot policy change already uses (soc: apple: sep: keep Touch ID across a boot policy change #545):
    • one rewrite per boot, shared with the policy window, of one kind-4 record that existed at probe;
    • never a delete, never another kind, and the shared roots still follow the level;
    • only after the record's previous value is durable in /var/lib/aurora-sep-xart-policy-previous.bin, as for a policy change;
    • the record is not added to Linux's list, so the next boot protects it again.
  • The log names the record: "allowed one rewrite of kind-4 record ... while Linux's identity keybag was created".
  • This includes cold-boot Macs (the M1 family, where the driver loads the enclave firmware). On an M1 Pro, keybag creation rewrites one pre-Linux attach record the same way. Until now that meant xart_guard=0. Both kinds of Mac run the same stub sepOS (13.5 here), so the risk to macOS is the same on both and the window applies to both. Whether that M1 record is kind-4 has not been confirmed. If it is not, the create is refused as before, and logged.
  • The create exchange waits up to 6 s, like a 13.5 key store's, because the saved value and the new slot are flushed inside it.

Unfinished create (keybag.rs, xart_guard.rs, sks.rs)

  • The intent now records the guard list's length in its UUID field. The field is CRC-checked, and older kernels still read it as an intent.
  • The enclave's new session records are listed before they are written. So when a later boot finds an intent and a list that has not grown, it knows the enclave kept nothing and sends the create again (may_retry_create).
  • An intent from an earlier kernel records no length. It is sent again only while the list is empty. That is the state this refusal left on the Fedora install, so it recovers without a manual step.
  • No guard now, a list that grew, or a create sent without a guard: the intent stays and so does EEXIST, as before.

Readiness on cold-boot Macs (xart_guard.rs, diag.rs, aurora-sep-ready)

  • A guarded cold-boot Mac used to report matching blocked for being cold-boot, on the grounds that its keybag could only be created with the guard off. That no longer holds, so it reports unverified like a warm-attach Mac until the guard refuses a write. aurora-sep-ready drops that reason, and its tests and the ABI doc follow.

Docs and packaging

  • XART-SAFETY.md: the creation table rows, the cold-boot notes, and new sections "The keybag creation window" and "An unfinished keybag create".
  • The Arch PKGBUILD checksums for XART-SAFETY.md and aurora-sep-ready are updated.

What still protects macOS's records

Every other session record that existed at probe stays refused, before, during and after the create. That covers the other six kind-4 records, both kind-3 records, and anything another Linux install made. Deletes of existing records are never allowed. Level 2 still refuses the shared roots. The one rewrite has to happen inside Linux's own first keybag creation, can happen once per boot, and is saved first. Nothing is added to Linux's list.

What happens to the ALARM install's Touch ID

Nothing on the ALARM side is read or written. Fedora does not reuse ALARM's keybag or enrolment: it creates its own keybag with its own secret and UUID, and the enclave puts it in its own lane through its own /chosen/apfs-preboot-uuid. ALARM's keybag, ref-key, catacombs and prints are files on its partition.

The one shared change is record 423ea61c. The enclave rewrites it while it creates Fedora's keybag, and ALARM's enclave reads the new version at its next attach. That is the same thing that happened after macOS rewrote the record this morning, though ALARM has not booted since then. I expect ALARM to restore its two enrolled fingerprints as it does now, but that is not verified yet. It is step 5 of the hardware test below. If it fails, the previous value is in Fedora's /var/lib/aurora-sep-xart-policy-previous.bin. Writing it back would not roll back the enclave's counters, so the evidence has to be kept and nothing reset.

Testing so far

  • drivers/soc/apple/ builds with no warnings with Fedora kernel-aurora's -12 config plus CONFIG_KUNIT=y and CONFIG_APPLE_SEP_KUNIT_TEST=y (kernel Rust 1.85.0, LLVM=1). rustfmt finds no new drift.
  • Host tests test_sep_ready, test_diag_sensor, test_packaging and test_ready_pam_hint pass, except test_gives_up_waiting. That one times out on this macOS host on the base commit too.
  • New KUnit cases cover the creation window's terms, its interaction with an allowance and with level 2, the list length kept from load, the retry rule, and the intent format, including the 52-byte intent from the stuck install. They have not run yet: the build VM has no qemu. They will run at module load on the test kernel below.
  • The aurora-wip copy is soc: apple: sep: let a second Linux install create its Touch ID keybag on M2 Pro/Max (aurora-wip) #860. The hardware-test kernel, kernel-aurora 7.3.0-12.sepfix1, is built from it by fedora-aurora's RPM workflow, with -12's config unchanged (run 41447978174, branch test/kernel-aurora-sepfix1, not for merge). KUnit is off in that kernel: the guard suites bump the driver's refusal counter, which would show up in the diag state under test.
  • aurora-silicon/linux has run no Actions since 30 Oct, so sep-source.yml (the arm64 KUnit compile) has not run on this PR.
  • Not tested on hardware yet.

Hardware test plan

On the J414s: Fedora on the test kernel from a cold power-on with no module parameter, then fprintd enrol and verify, a reboot to prove persistence, ALARM's restore and verify, and a macOS Touch ID check. The full step list is in the thread. Results will be added here.

🤖 Generated with Claude Code

On a MacBook Pro M2 Pro (T6020, J414s), a second Linux install never got
a Touch ID keybag. CREATE_KEYBAG makes the enclave rewrite one existing
kind-4 xART record. That record is one of the four kind-4 records the
enclave reads at every attach. A 2026-09-26 capture from the first Linux
install already has it, and macOS's enclave rewrote it on 2026-11-02
while no Linux install was running. It predates every Linux install, so
it is never on Linux's list, and xart_guard=1 refused it. The enclave
did not fail the create. It stopped answering, and the hardware RNG and
every later key-store request timed out. The driver also kept its create
intent, so every later boot refused to create a keybag ("identity keybag
state is ambiguous: EEXIST"), and trusted keys failed with EEXIST.

The other Linux install is not the cause. Every guarded keybag creation
on that Mac asks for the same rewrite. The first install has a keybag
only because it was made before the guard existed. An M1 Pro (T6000)
rewrites one pre-Linux attach record the same way. It runs the same
stub sepOS, so the risk to macOS is the same, and so far it has needed
xart_guard=0.

Run the identity CREATE_KEYBAG in the window a boot policy change
already uses. It allows one rewrite per boot, of one kind-4 record that
existed at probe. It never allows a delete or another kind, the roots
follow the level, the previous value is saved on the host first, and
nothing is adopted. The exchange now waits up to 6 s, as a 13.5 key
store's does, because the saved value and the new slot are flushed
inside it. Every other session record that existed at probe stays
refused, before, during and after the create. That includes any record
another Linux install made.

Make an unfinished create recoverable. The intent now records how long
the guard's list was. New session records are listed before they are
written, so a later boot whose list has not grown knows the create left
nothing behind, and sends it again. An intent from an earlier kernel
records no length. It is sent again only while the list is empty, which
recovers the installs this refusal already left stuck.

A guarded cold-boot Mac is no longer reported as matching "blocked"
just for being cold-boot. That rule assumed its keybag could only be
created with the guard off. It is now "unverified", like a warm-attach
Mac, until the guard refuses a write. aurora-sep-ready drops the
matching reason, and the ABI doc and XART-SAFETY.md follow.

KUnit covers the window's terms, the list length kept from load, the
retry rule, and the intent format, including the zero-UUID intent that
earlier kernels wrote.

Signed-off-by: DjDeveloperr <[email protected]>
Assisted-by: Claude:claude-opus-5-5
@RyanTheTide

Copy link
Copy Markdown
Contributor

KUnit results for the new SEP cases, since the build VM couldn't run them. Run with kunit.py run --arch=arm64 under qemu on the buildbox, on aurora-wip c243830 with #860 merged (the same commit as 856), against plain c243830.

  • apple_sep_xart_guard: 33 of 33 pass (27 on the base).
  • apple_sep_keybag: 3 of 3 pass (new suite).
  • Every other SEP suite gives the same result as the base.
  • Four apple_sep_host_store cases fail, but they fail the same way on plain aurora-wip, so they aren't from this PR: existing_empty_and_zero_files_are_initialised, a_created_flag_keeps_valid_records_and_retries_blank_files, interrupted_creation_is_retried and blank_creation_is_distinguished_from_damaged_state, all "host-state store failed validation (Size)".

Merged with the other open aurora-wip PRs, the apple-dcp host selftests also stay at the base count. I'm leaving this unmerged until the J414s run in your test plan is posted, since we don't have that hardware and the change rewrites a macOS-side SEP record.

@DjDeveloperr
DjDeveloperr merged commit e4d0445 into integration/aurora Nov 2, 2026
notmysegv pushed a commit to notmysegv/linux that referenced this pull request Nov 4, 2026
Bring integration/aurora up to aurora-wip 437edfa, the source of the
7.3.0-aurora-fleet14b kernel that was promoted on the M1 Pro, M2, Neo
and J616s on 2026-11-01. This takes the aurora-wip work since the
two branches diverged, including the 2026-11-01 sync of
integration/aurora into aurora-wip (aurora-silicon#761), up to and including aurora-silicon#764.

integration/aurora had two changes aurora-wip lacked at this point:
the tipd late USB4 router fix (aurora-silicon#855) and SEP keybag creation in the
shared xART window (aurora-silicon#856). aurora-wip carries the same patches as aurora-silicon#858
and aurora-silicon#860, which come in with a later batch. Two conflicts, both where
the two sides added lines next to each other: the KUnit prototype list
in tps6598x.h (both kept, in aurora-silicon#858's order) and the aurora-sep PKGBUILD
checksums (recomputed from the merged files; they match aurora-silicon#860's). The
merged tree is identical to aurora-wip 437edfa with the aurora-silicon#858 and aurora-silicon#860
patches applied.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
notmysegv pushed a commit to notmysegv/linux that referenced this pull request Nov 4, 2026
…nto integration/aurora

Bring integration/aurora up to the aurora-wip tip 9ff2b9a. After this
merge the two branches have the same tree.

The range contains the fleet14o source c243830 (aurora-silicon#857, aurora-silicon#858, aurora-silicon#795,
aurora-silicon#859), which was promoted on all four machines on 2026-11-02 and 03, and
the merges after it: aurora-silicon#861 (apple-dcp selftest stubs for aurora-silicon#858), aurora-silicon#860
(SEP keybag in the shared xART window, the aurora-wip copy of aurora-silicon#856),
aurora-silicon#724 (J616s boot NOR, both parts), aurora-silicon#779 (ALS colour temperature ABI),
aurora-silicon#862 (J700 GD25UF16E boot NOR, the Neo bless fix), aurora-silicon#863 (J616s ANE H16
start stall), aurora-silicon#797 (T6000 DCS whole-word writes) and aurora-silicon#803 (G17 keeps
innocent clients alive across another client's recovery).

aurora-silicon#858 and aurora-silicon#860 make the same changes integration/aurora already had as
aurora-silicon#855 and aurora-silicon#856, so they merge without conflicts.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide
RyanTheTide deleted the sep/keybag-create-xart-window branch November 7, 2026 12:06
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