Repository navigation
soc: apple: sep: let a fresh install create its Touch ID keybag - #212
Conversation
…SEP-xART locker Blessing a newly installed OS from macOS leaves a SEP-xART locker (kind 4) in a pending state. Every OS's enclave reads that locker at attach, and the next enclave to save its state commits it. macOS's enclave does that at boot. Under Linux the first save is the first CREATE_KEYBAG, so on an install whose first boot is Linux the guard refused the commit. The create then got no reply, the enclave stopped answering until a restart, and Touch ID could only be set up after booting macOS once. While the first CREATE_KEYBAG of an install whose list is loaded and empty runs on a warm-attach Mac at level 1, let the enclave rewrite one existing kind-4 locker. The locker is not listed as Linux's, so later rewrites are refused as before. Deletes, kind-3 lockers and a second rewrite are still refused, and cold-boot Macs get no window: their create rewrites a pre-Linux record for a different reason. Tested on an M2 Max (J416c, system firmware 26.6.2), reinstalled with the Omarchy Mac installer and with no macOS boot before Touch ID setup. The guard allowed the one commit (2715 to 1137 bytes, as macOS's enclave makes it), the keybag was provisioned and the list stayed empty. Enrolment, match, trusted-key seal and load, restore and match after a restart, macOS Touch ID unlock and keychain, then restore, trusted-key load and match back in Linux all passed, with no refusal. Signed-off-by: Marcelo Alcantara <maralc@gmail.com>
A CREATE_KEYBAG that times out keeps its intent record, so every later create fails with EEXIST in case a keybag exists unnamed in the enclave. When the guard refused one of the enclave's xART writes during the create, the enclave could not save the state the create needed, so it kept no keybag, and the enclave typically stops answering until a restart. The intent then blocks Touch ID setup for good, and the owner's only way out is removing /var/lib/aurora-sep-keybag.bin by hand. Mark such a create retryable, so the next boot tries again. Signed-off-by: Marcelo Alcantara <maralc@gmail.com>
[Medium impact] The PR appears safe to merge; no new actionable issues were found. SummaryLets a fresh install create its first Touch ID keybag on warm-attach Macs at guard level 1.
The earlier torn-list finding is fixed:
|
…ntry load() counts whole entries, so a list holding only a torn first entry left the append offset at 0 and opened the first-setup window. A torn entry is still an earlier setup: open the window only when the list file is empty. Also update the aurora-sep package's checksum for the XART-SAFETY.md change. Signed-off-by: Marcelo Alcantara <maralc@gmail.com>
…efused" This reverts commit 6848e89. The retry had no profile or level gate. On cold-boot Macs at the default guard level (T8103, T6000), where the create's rewrite of a pre-Linux record is refused, every boot would mark the create retryable, try again, be refused and wedge the key store, instead of failing fast with EEXIST after the first boot. A refused write also does not prove the enclave kept no keybag: an allowed root write comes before it. Keep the intent fail-closed. Signed-off-by: Marcelo Alcantara <maralc@gmail.com>
The first-setup window opened whenever the owned list was empty, and a successful first create leaves it empty: the committed locker is not adopted. Resetting Touch ID removes the keybag but keeps the list, so the next create on the same install got the window again, and the enclave could rewrite a SEP-xART locker that was no longer pending. Record the window as consumed before it opens: write a marker as the list's first entry and flush it before the create is sent. The marker is kind 0, which no record has, so it lists nothing as Linux's; older kernels read it as one torn entry and append after it. If it cannot be made durable, the create is not sent and the intent is dropped as retryable. The window now also requires level 1 when it opens, so level 2 consumes nothing. Document that the window allows the first pre-existing kind-4 rewrite, with nothing identifying it as the pending locker, and the marker. Signed-off-by: Marcelo Alcantara <maralc@gmail.com>
|
Hand build replaced by the shipped Edge package: linux-aurora 7.2.11.aurora6-1 (CI run 40185970994, head 7876c8e, success; Edge bumped aurora5-1 -> aurora6-1 minutes after the run). Installed through the shipped packages and their hooks (no hand packaging), one-shot boot of the linux-aurora entry, stock default (the 12.6 preempt entry) untouched. Tested on the 14-inch M2 Max:
CI on this PR: 12 pass, 2 skipped. Regressions: none found. omarchy-m-test check list matches the stock run except: boot.kernel-package now PASS (the running kernel is the installed package, which is the point of this run), input.auto-keyboard-light PASS (already passing on the earlier tip build; stock 12.6 fails it — improvement, not regression), hardware.drivers counts the Not tested: this machine has no fingerprint reader (fprintd: "No devices available"), so the Touch ID keybag path in this PR is covered only down to the SEP/xart first-setup guard code compiled in and the SEP attach staying healthy; the actual keybag create path needs a machine with the reader. M3 paths in the other merged PRs are not exercised on this machine. |
|
Read 6848e89 ("Retry a keybag create whose xART write was refused") against what happened on a 14-inch M2 Max. Short answer: our result is not the case it fixes, and I did not run that commit. What the commit does, as I read it: when What happened here (aurora6 7.2.11.aurora6-1, which contains #212):
So: the first-keybag create on an M2 Max worked with #212 once writes were enabled; the one refusal-style message we saw came from provisioning being switched off by the read-only file, not from a refused enclave write. A refused create is the path 6848e89 covers, and we did not hit it. Not measured yet: a real match after enrollment, survival across a reboot, xART counts after enrollment, and macOS on that Mac. I will add them here when done. |
|
Result on the 14-inch M2 Max, aurora6 7.2.11.aurora6-1 (contains #212), added to my comment above:
The max revision moved by 10 (the anti-replay counter going forward during enrollment). The guard reported
Two things outside the kernel that blocked the first tries are written up in omacom/omarchy-pkgs#1614 (menu row hidden by a stale guard after the package switch; duplicate |
Summary
Fixes Touch ID setup on a fresh install of an M2 Max (and likely other warm-attach Macs), reported in #209.
Blessing a newly installed OS from macOS leaves the SEP-xART locker that every OS's enclave reads at attach in a pending state. The next enclave to save its state commits it. macOS's enclave does that at boot. Under Linux the first save is the first
CREATE_KEYBAG, so the guard refused the commit:CREATE_KEYBAGgot no reply, the enclave stopped answering until a restart, and Touch ID only worked after booting macOS once.xart_guard: first-setup window. During the firstCREATE_KEYBAGof an install whose owned list is loaded and empty, on a warm-attach Mac at level 1, the enclave may rewrite the first existing kind-4 (SEP-xART) locker it writes. Nothing identifies that locker as the pending one; the window allows any one pre-existing kind-4 rewrite. The locker is not adopted. Deletes, kind-3 (USER-xART) lockers, a second rewrite and level 2 stay refused, and cold-boot Macs (M1 family) get no window. Dj agreed to the exception, on condition thatkeyctland fprintd keep working across reboots.EEXIST) as before.Evidence
M2 Max (J416c, T6021), system firmware 26.6.2, guard level 1, real preboot UUID throughout. Kernel
7.2.11.aurora5-1.1: the current omarchy-pkgs pin (99cb1a7) plus this branch's diff, built with the package's own PKGBUILD.Fresh install with Omarchy Installer 2.3.8 (Remove, then Install, edge), no macOS boot before Touch ID setup.
CREATE_KEYBAGxART guard: allowed the enclave to commit an existing kind-4 locker during this install's first keybag creation;op 0x061153 B status 0;sks: identity keybag provisioned; locker now 1137 B; owned list emptyfprintd-verifykeyctltrusted keynew 32/ pipe /loadTouch ID: restored 1 enrolled identity, blob loads, matchAPEventTouchIDMatch),_keychainPasswordReset:0, _keychainMovedAside: 0xart_guard_refusals=0throughout.Earlier the same day, unpatched
aurora4: the refusal, the hang and the permanentEEXISTintent are reproduced in #209. The guard and store kprobe traces, gigalocker dumps at each step and macOS's AppleSEPXART log (which shows macOS reading the same four lockers under its own OS UUID) are available on request.Not tested
CONFIG_KUNIT=yandCONFIG_APPLE_SEP_KUNIT_TEST=y, but haven't been run (CONFIG_KUNITis off in the package config).Merge Danger
Door: two-way
The rule only relaxes during one
CREATE_KEYBAGper install, on an install whose owned list was empty, and it never adopts the locker. Reverting restores the old refusal; a marker left in the list is ignored by older kernels as one torn entry.Blast Radius: the first Touch ID setup on warm-attach Macs (M2, M2 Pro/Max, M3) at the default guard level.