Skip to content

soc: apple: sep: keep Touch ID across a boot policy change - #262

Open
RyanTheTide wants to merge 4 commits into
omacom:integration/aurorafrom
aurora-silicon:fix/omacom-sep-boot-policy-change
Open

RyanTheTide wants to merge 4 commits into
omacom:integration/aurorafrom
aurora-silicon:fix/omacom-sep-boot-policy-change

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

This ports the SEP boot policy fix from aurora-silicon/linux (aurora-silicon/linux#545 and aurora-silicon/linux#543) onto integration/aurora here. Only the SEP driver and tools/aurora-sep are touched.

Hardware tested. The manual one-time allowance brought Touch ID back on a J616s (T6040) with its existing enrolment. The automatic path then ran on the same J616s on 2026-10-29 with the aurora-silicon version of this fix: two normal boots made no record rewrite, and a Stage 1 change with nothing armed made exactly one, by itself, with Touch ID and its fingerprints kept.

What goes wrong

Installing a new Stage 1 changes the boot policy the Mac keeps for Linux. On the J616s a reinstall that only changed the kernel collection hash was enough. The first time Linux's identity keybag is unlocked under the new policy, the enclave rewrites one kind-4 session record that already existed. Linux did not create that record, so the xART guard refuses the write. The enclave then never answers CHANGE_LOCK_STATE, the machine ref-key stays down and every trusted-key seal fails with EIO. Touch ID is gone until the policy changes back, even though the keybag, ref-key and fingerprints are all intact.

On top of that, aurora-sep.service was ordered before multi-user.target and aurora-sep-load kept retrying the seal every 100 ms for two minutes. So the same boot also sat for about two minutes before userspace finished, logged the seal warning over a thousand times, and gdm waited up to 90 s on Touch ID before showing the login screen.

The fix

Under an unchanged policy that first unlock rewrites no session record at all, so a rewrite inside it is the policy change. The driver now lets exactly one through by itself:

  • only during the first unlock of an identity keybag that already existed, once per boot. A keybag or ref-key created this boot closes the window
  • only one kind-4 session record, only a rewrite and never a delete or a shared root
  • only once the record's previous value is durable in /var/lib/aurora-sep-xart-policy-previous.bin, otherwise the write is refused
  • the record is not added to Linux's list

There is no module parameter for it. Refused records are now named by their session id in the log, which the list file already holds anyway.

For a change the window does not cover, aurora-sep-policy-change backs up the gigalocker extent, the driver's host files and the fingerprints, then leaves a one-time allowance in /var/lib/aurora-sep-xart-allow-once.bin. The driver empties that file at probe before it uses it, so an allowance lasts one boot, on the same terms as above.

This sits next to the existing first-setup window from #212 without changing it. That one covers CREATE_KEYBAG on a fresh warm-attach install, this one covers the first unlock of a keybag that already existed, and the guard checks the first-setup window first.

Userspace changes:

  • aurora-sep.service is no longer ordered before multi-user.target. fprintd and aurora-sep-ready still wait for it
  • aurora-sep-load stops at the first xART guard refusal and says what to run, instead of retrying for two minutes. When the driver followed a policy change it logs the m1n1, iBoot and OS firmware versions
  • the login screen no longer waits for Touch ID. A new aurora-sep-greeter-refresh.service shows it again once Touch ID is up, only if nobody has logged in yet
  • a failed trusted-key seal warns once and then goes to dev_dbg
  • XART-SAFETY.md describes the event, the automatic update and the allowance. Arch and Fedora packaging pick up the new files

Differences from the aurora-silicon version

  • xart_guard.rs keeps the first-setup window and its consumed marker. The list entry encoder takes a magic so the allowance file can share it
  • packaging keeps this tree's file list (no OS-IDENTITY.md) with recomputed sha256sums, pkgrel 13 and spec release 1-8

Testing

  • arm64 build of Image and modules on this branch (defconfig plus asahi.config, APPLE_SEP=m, APPLE_SEP_KUNIT_TEST=y) with LLVM, no warnings. Clippy reports nothing in the changed files
  • KUnit under QEMU arm64, all apple_sep suites pass (127 tests, 33 in apple_sep_xart_guard). The new cases cover named and first-of-kind allowances, the policy window's one kind-4 rewrite, and new or listed records being left alone. The existing first-setup cases are unchanged and still pass
  • hardware: manual allowance and the automatic path verified on T6040 (J616s), see above

🤖 Generated with Claude Code

aurora-sep-load seals and unseals a test key every 100 ms for up to two
minutes while it waits for the machine ref-key. Each failed seal logged
a warning, so a J616s boot whose ref-key was not up logged the same line
2290 times and buried everything else at warning level.

The first failure keeps the warning that says what is wrong. The
repeats only say the caller is still waiting, so they go to debug.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
aurora-sep-greeter-fingerprint.service held gdm back until
aurora-sep-ready.service finished, so the login screen would find the
reader and its fingerprints. The enclave takes tens of seconds after boot,
and when it does not come up the job timeout holds gdm until 90 s after
boot. On the J616s the desktop appeared at 95 s; with automatic login that
wait bought nothing at all.

The greeter unit now only prepares the login screen's shell and no longer
waits for Touch ID. A new aurora-sep-greeter-refresh.service runs once
both gdm and Touch ID are up. When nobody has logged in yet, it shows the
login screen again so it asks fprintd for the reader again and offers
fingerprint. With automatic login, or once anyone has logged in, it
changes nothing, since restarting gdm would end their session. Enabling
the greeter unit enables the refresh unit with it.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
A new Stage 1 changes the boot policy the Mac keeps for Linux. The first
time Linux's identity keybag is unlocked under the new policy, the
enclave rewrites one session record that already existed. Linux did not
create it, so the xART guard refuses the write. The enclave then never
answers CHANGE_LOCK_STATE, the machine ref-key stays down and every
trusted-key seal fails with EIO, so Touch ID is gone until the policy
changes back. On a J616s (T6040) this happened after a Stage 1 reinstall
that changed only the kernel collection hash.

Under an unchanged policy that first unlock rewrites no session record at
all, so a rewrite inside it is the policy change. Let exactly one through:
during the first unlock of an identity keybag that already existed, once
per boot, one kind-4 session record, a rewrite and never a delete, and
only once the record's previous value is durable in a host file. The
record is not added to Linux's list. A ref-key created this boot closes
the window.

For a change the window does not cover, aurora-sep-policy-change leaves a
one-time allowance in /var/lib/aurora-sep-xart-allow-once.bin naming the
refused record, or before a planned change the first existing kind-4
record asked for. The driver empties the file at probe before it uses
it, so an allowance lasts one boot, on the same terms.

Name refused records by their session id. Linux's list of records
already holds session ids, so this reveals nothing new.

On the J616s the allowance restored Touch ID with the existing enrolment:
one kind-4 record and one shared root were rewritten, the other seven
session records kept their revisions, and the enrolled finger matched.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…r hold the boot for it

aurora-sep.service was ordered before multi-user.target, so a boot whose
enclave did not come up waited for the loader's full two-minute timeout.
On a J616s after a Stage 1 reinstall, userspace took 2 min 1.6 s. It now
has no ordering before multi-user.target. fprintd and aurora-sep-ready
still wait for it, and the login screen no longer does.

aurora-sep-load retried the seal every 100 ms for those two minutes even
when the xART guard had refused the enclave's write, which does not go
away by waiting. It now stops at the first refusal and says what happened
and what to run. The same J616s reached graphical.target in 11.1 s, with
one seal failure logged instead of about 1,100.

The driver now follows a boot policy change by itself. When it logs
that it did, aurora-sep-load notes the m1n1, iBoot and OS firmware
versions the boot came up with. For a change it could not follow,
aurora-sep-policy-change backs up the gigalocker, the driver's host
files and the fingerprints, then arms the driver's one-time allowance:
with no arguments for the record this boot refused, or with --expect
before a planned change. XART-SAFETY.md describes the event, the
automatic update and the allowance.

The Arch package also gets the aurora-sep-greeter-refresh.service link
that its PKGBUILD already lists.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Collaborator Author

Tested on the J616s (T6040), 2026-10-29, with the aurora-silicon version of this fix (aurora-silicon/linux#545, merged there as b0465ae):

  • Two normal boots: no record rewrite, no refusal, no seal failure.
  • Stage 1 change from m1n1 to aura with nothing armed: on the first boot the guard allowed one rewrite of an existing kind-4 record by itself and kept its previous value. Trusted keys sealed and unsealed in 4 s, and aurora-sep-load reported the policy change with the fingerprints kept.

The driver logic here is the same; this tree's version also keeps the first-setup window from #212, which the KUnit cases above cover. Marking ready.

@RyanTheTide
RyanTheTide marked this pull request as ready for review October 29, 2026 07:57

@scottjones scottjones left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for porting this, and for the write-up in XART-SAFETY.md. The userspace half reads well to us: aurora-sep-load stopping at the first refusal instead of retrying for two minutes, aurora-sep.service no longer holding multi-user.target (DefaultDependencies=no does drop the implicit After= from the target), and the one-time seal warning (trusted.rs:109-118). The guard change is the part we want to talk through before it goes in, since it loosens the guard on every Mac where it runs.

Scope on our Macs, as we read 8ee9bb2:

  • The window and the allowance only run where the guard runs: xART writes on and a guard level set (sep.rs:855). That's T8103, T6000, T6020/T6021, T8112 and T8122 J613/J615 (profile.rs:550-589). On the Neo the guard is off (profile.rs:353), so none of it runs there.
  • This tree has no T6030/T6031/T6040 profile, so the driver doesn't bind on the J616s at all. The hardware results in the description come from the aurora-silicon tree, and nothing has run this port on a Mac. Have you, or anyone, seen the Stage 1 rewrite on an M1, M2 or M3, or only on the T6040?

Things we'd like changed or answered:

  • The manual allowance isn't limited to the identity unlock. take_allowance_for (xart_guard.rs:631-635) uses it before it looks at the window, so a --expect (first of kind 4) allowance covers the first existing kind-4 rewrite at any point in that boot. The description and XART-SAFETY.md say "on the same terms". xart_guard.rs:219 notes that on a T6000 a match rewrites records that existed before it, so there it could go to a match instead of the policy record. Could the allowance also require the window, or at least FirstOfKind?
  • A stale allowance can outlive "one boot". The file is only read and emptied in Guard::open (xart_guard.rs:430), which only runs when writes are on and a guard level is set (sep.rs:855). With xart_writes=0 (the default in #180), xart_guard=0, or the Neo, an armed file just stays there until some later guarded boot. That boot might not be the policy change. Could the tool refuse to arm when this boot has no guard, or could the driver empty the file at probe either way?
  • Which record is it? The window passes any existing kind-4 record that isn't on Linux's list (xart_guard.rs:636). On the J616s there were seven, and Linux had listed none. What tells us the one the enclave picks is Linux's? The driver knows Linux's OS UUID (sep.rs:1537-1558). If the record's session id relates to it, checking that would make the window much narrower. XART-SAFETY.md says the saved previous value is evidence and not an undo, so how narrow the window is is the real protection.
  • Not every identity unlock goes through the window. ensure_restored_after unlocks the special handle at sbio.rs:3538/3543 outside policy_window. In the packaged boot the loader's seal comes first, because fprintd waits for aurora-sep.service. But a manual modprobe, or anything that opens /dev/sep-bio first, makes that unlock the first one. Does that unlock trigger the rewrite too? If it does, it needs the window as well.
  • After a failed save the window or allowance is already spent (xart_guard.rs:608-611, xart_store.rs:400-423). That's fine for the automatic path, since the next boot tries again. But refuse_unsaved logs "could not save ...", and aurora-sep-policy-change's REFUSED pattern only matches "refused to rewrite", so running the tool with no arguments then says nothing was refused. Either the pattern should match it, or the loader message should point at --expect.
  • load-driver:85-87 now exits on any refusal this boot, and that also stops aurora-sep-ready and fprintd (both Requires=). Before, the loop kept retrying until the timeout. Can a refusal that has nothing to do with the seal happen before the first seal works on a cold-boot M1?

#257: this conflicts in xart_guard.rs. Whichever lands second should send the two refusals in check() and the new refuse_unsaved() through report_refusal(). The new KUnit refusals would otherwise leave counts in diag on a test kernel. It merges cleanly with #180, #251 and current integration/aurora. With #180's xart_writes=0 none of this runs and Touch ID needs writes anyway (sbio.rs:3421). load-driver:42 still loads with writes on, so the only #180 interaction we found is the stale allowance above.

On our side we'd run a no-change boot on the J613 with this kernel and check for no "allowed one rewrite" line, no policy-previous file, zero refusals and Touch ID still matching. We'd also run --expect, --status and --cancel there. We don't have a reversible policy change to test on yet.

For the RC we'd take the userspace changes and the warn-once. We'd hold the guard window until it has run on at least one SoC this tree supports and the allowance is gated as above.

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