Skip to content

soc: apple: sep: xart_guard_pin on the M1 Air: hold the window through the first activation, pin up to three lockers (builds on #486) - #506

Closed
malik-na wants to merge 10 commits into
integration/aurorafrom
sep/xart-guard-pin-j313
Closed

malik-na wants to merge 10 commits into
integration/aurorafrom
sep/xart-guard-pin-j313

Conversation

@malik-na

@malik-na malik-na commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Tested on hardware: MacBook Air M1 (J313). This head was booted on the J313 with xart_writes=1 provision_keybag=1 xart_guard_pins=1 and the guard at level 1:

  • Setup: three pre-Linux lockers pinned, keybag provisioned, xart_guard_refusals 0.
  • Enrol and match: enrol completed, 3 of 3 matches.
  • Reboot: the enrolment restored, 2 of 2 matches, refusals 0.
  • KUnit: the SEP suites ran on the J313 itself: apple_sep_xart_guard 42 of 42, every suite passing.

Why

Touch ID on cold-boot Macs (M1 family) with the xART guard kept on. Today the only way to set it up there is xart_guard=0, which lets the enclave rewrite or delete any macOS session record.

Summary

Builds on #486, whose commit is included unchanged with its author.

#486 as posted fails on the J313. Its first setup rewrites three pre-Linux SEP-xART lockers, not one, and none at the create:

  • two at the COPY_KEYBAG after the create (tags da70de89, 140a890d);
  • one during the first activation, about 280 ms after its LOAD_KEYBAG reply (5700cc64).

All three were present in a raw copy of the iBoot System Container taken before Linux's first xART write.

This PR:

Evidence

Four attempts on the J313 led to the window design:

Attempt Kernel Result
1 #486 COPY_KEYBAG rewrote da70de89; refused, provisioning failed
2 window through provisioning da70de89 pinned, 140a890d refused
3 plus two pins keybag provisioned; 5700cc64 refused in the activation; the enclave then answered nothing more that boot
4 window to the end of the first activation, three pins all three pinned, refusals 0, ready

During the review fixes, closing the window right after sks_recover() was tried on the J313. It refused the third locker again: the LOAD_KEYBAG reply came at 12.386 s and the rewrite at 12.662 s. So the window ends when the first activation returns.

The owner reports macOS Touch ID still works after a guarded setup on this Mac. FileVault and the keychain were not checked one by one.

Verified

  • KUnit on the J313:
    • A kernel with only the two new edge-case tests fails exactly those two (39 of 41).
    • The fixed tree passes 42 of 42 apple_sep_xart_guard and every other apple_sep suite.
    • A test kernel's guard tests bump the same refusal counter the real driver reports, so the Touch ID status reads blocked on a KUnit boot. soc: apple: sep: Let a cold-boot Mac's owner pin the one shared xART locker #486's tests do this too.
  • Host suites: aurora-sep and aurora-sep-slow pass 42 of 43. The one failure, test_desktop_fixes.py, needs a commit a shallow clone lacks, and fails the same way at soc: apple: sep: Let a cold-boot Mac's owner pin the one shared xART locker #486's head.
  • Independent review: each review point and each later fix was checked by a separate agent against the code. They found a test that could not fail, a KUnit test that failed on correct code, reset-hint false positives and stale docs. All are fixed in the pushed commits.

Not tested

  • other cold-boot Macs (J293, J274, J316s, J314s), where the number of lockers and when they are rewritten is unknown;
  • a second user, deleting a print, lockout, and sleep and resume;
  • a later CREATE_KEYBAG after a Touch ID reset under the pin.

🤖 Generated with Claude Code

…locker

On a cold-boot Mac (M1 family), creating the identity keybag rewrites one
session record from before Linux. The xART guard refuses that, so Touch ID
there needs xart_guard=0, which lets the enclave rewrite or delete any
session record on the Mac in order to allow one.

Add xart_guard_pin (default 0). With it set on a cold-boot Mac at level 1,
the first-setup window opens for the install's first CREATE_KEYBAG. The
first existing kind-4 locker the enclave rewrites in it, if the enclave
read that locker since probe, is recorded in the list as pinned before the
write lands. The enclave may rewrite the pinned locker from then on, on
boots where the parameter is set and it has read the locker. The locker is
never deleted or listed as Linux's, and every other record from before
Linux stays refused. Without the parameter nothing changes: a cold-boot
Mac gets no window, and a pin in the list is not honoured.

The guard no longer has a default first-setup rule. sep.rs derives it from
the bootstrap and the parameter, and sks.rs asks the guard for the window
on every platform instead of checking the bootstrap itself.

A keybag created this way has its own record on the list, so matching
reads "unverified" on such a Mac instead of "blocked". A new shim call
moves matching without clearing the refusal count, and a refusal that
lands meanwhile still leaves "blocked". The driver logs a CRC-32 tag of
the pinned locker, and of any kind-4 locker it refuses under the
parameter, so a refusal can be compared with the pin across boots.

The pin is a new kind of list entry, which a kernel without it reads as
one unreadable entry and ignores.

Not run on hardware. Whether macOS tolerates Linux's rewrites of that
locker is as open as it is with xart_guard=0; see XART-SAFETY.md, which
also says what must hold before the first setup under the pin.

Assisted-by: LLM
Signed-off-by: Poul Guo Skov <80295985+poulguoskov@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@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 running this on a J313. The tag-to-gigalocker cross-check is the kind of evidence #486 was missing. A few things before this is ready:

  1. Two host tests fail at this head. Both pass at #486's head.

    • tools/aurora-sep/tests/test_diag_sensor.py (test_the_first_setup_window_brackets_the_create, line 333) still expects store.close_first_setup() inside sks_provision_identity_keybag. It needs updating for the new close.
    • test_packaging.py fails because XART-SAFETY.md changed and the PKGBUILD sum (line 44) didn't. Running updpkgsums fixes it.
  2. The window can now stay open much longer than one setup (sks.rs:708, sbio.rs:1396).

    • The only close is the SetupWindow drop in activate_touchid, which runs on the first open of the bio device.
    • Every failure return in sks_provision_identity_keybag after open_first_setup now leaves the window open for the rest of the boot, because run_bringup returns before register_bio. That covers a missing CREATE reply, a bad status and a failed COPY_KEYBAG. Under Pin, up to three read lockers can be pinned for good in that time.
    • The change also applies to the warm-attach Macs at guard level 1 (J414s, J415, J613), by default, on their first setup. They don't need xart_guard_pin (xart_guard.rs:157). If the create doesn't use their window, it now stays open through COPY_KEYBAG and the whole first activation, and that window passes one rewrite of any existing kind-4 record, with no read check. I've only read this in the code and none of them were tested with it.
    • I'd hold the window only under Pin, close it on every failed provisioning exit, and close it right after sks_recover instead of at the end of activation.
  3. The third pin can only be taken in the provisioning boot. The window opens only on an empty list. Say activation fails before LOAD_KEYBAG (Store::open, enable_sbio, keybag::read or sks_ready), or nothing opens the device that boot. The list then holds the marker and two pins, and every later boot refuses 5700cc64 at LOAD_KEYBAG. By your attempt 3, that leaves the enclave silent for the rest of each boot. announce_pin takes the "pinned" branch, so the reset hint isn't printed either. The normal path with aurora-sep-ready avoids this, which fits your run, but it needs a recovery story or a louder log.

  4. The two #486 findings still reproduce here. With a list read that fails partway, the guard reports the list as not loaded but still lets a read, pinned locker be rewritten. A saved pin that's absent at probe gets adopted as Linux's. Both matter more with three pins.

  5. omarchy-mac can't tell this kernel from #486's. The diag abi file still says 2, and the only visible change is xart_guard_pin's help text. #162 has to check this before offering Touch ID on the J313, and the driver isn't loaded at that point. A new parameter name, or a version that modinfo shows, would let it.

Smaller: the module docs, the FirstSetup and Setup::Pin docs and XART-SAFETY.md's "Fresh installs" text still describe one locker and a create-only window. SetupWindow.open is always true.

I ran the guard's 39 tests on the host with a stand-in for the kernel crate, since I have no QEMU here, and they pass. Breaking MAX_PINS or the "Used once full" rule makes them fail, so the new tests do cover the pin logic. Nothing covers the window's lifetime in sks.rs/sbio.rs.

malik-na added a commit to omacom/omarchy-mac-pkgs that referenced this pull request Nov 19, 2026
From the review of #162:

- touchid-eligibility records unsupported:kernel on the J313 unless
  `modinfo -p apple_sep` lists xart_guard_pins (omacom/linux-aurora#506).
  A kernel with #486's xart_guard_pin pins one locker at the create and
  cannot finish the setup; a built-in driver lists no parameters and is
  refused too, so the one-time invitation never leads to a setup that
  cannot finish.
- touchid-options writes xart_guard_pins=1 on the J313.
- Before loading on the J313, touchid-enable sets aside an earlier try's
  guard list and uncommitted keybag (anything without the driver's magic
  and a committed state) in /var/lib/aurora-sep-touchid-retry-<time>/, so
  the pin window opens again after a try that failed on an older kernel.
  A committed keybag keeps its list; any failed move fails the setup.
- Tests: the kernel check against #506, #486 and parameter-less kernels;
  the set-aside for a list, a header, both, an unwritten file and a
  committed keybag; the M2 Max's options carry no pin. The manual says
  Touch ID is offered on the M1 Air only with such a kernel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
malik-na added a commit that referenced this pull request Nov 19, 2026
…d an absent locker

Two cases from the review of #486 (matthetherington) and #506 (scottjones),
as KUnit tests through check():

- A list whose read fails partway is reported as not loaded, but the pin
  and the owned record parsed before the failure still count: the pinned
  locker and the listed record can be rewritten.
- A pin saved for a locker that is absent at probe takes the ordinary
  adoption path: the locker is listed as Linux's and can be deleted.

Both fail at this commit; the next one fixes them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
malik-na added a commit that referenced this pull request Nov 19, 2026
…pins, hint the reset

From the review of #506:

- The first-setup window outlasts the create only under the pin rule
  (Setup::Pin). Without it, as on the warm-attach Macs at level 1, the
  window closes right after the create exchange, as in #486. Under the pin
  rule a SetupWindow closes it on every failed provisioning exit and hands a
  successful one to the first activation, which closes it on any exit before
  LOAD_KEYBAG and right after sks_recover() otherwise.
- The parameter is now xart_guard_pins, so `modinfo -p apple_sep` tells this
  rule (up to three lockers, create to first LOAD_KEYBAG) apart from #486's.
- When the guard refuses a locker the enclave read on an install whose
  window is spent and whose pins are not full, it logs that the first setup
  ended early and how to reset.
- The module, FirstSetup and Setup::Pin docs, XART-SAFETY.md and the
  parameter's help describe up to three lockers and the window's span; the
  aurora-sep package's checksums follow.
- The source-order test of the create follows the new window: held from the
  create, closed unless pinning, handed to the first activation, closed
  there after sks_recover().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@malik-na

Copy link
Copy Markdown
Member Author

Thanks for the careful read. Addressed in 393a21f..58e20b6. Each fix was checked by a separate agent against the code, and the final tree ran on the J313: KUnit there, plus a fresh guarded setup, enrol, matches and a reboot.

1. Host tests. Both pass. test_the_first_setup_window_brackets_the_create now checks the new contract:

  • provisioning holds the window across the create and hands the decision to the guard (end_create);
  • activate_touchid takes its hold before its first fallible step and releases it only on return.

The PKGBUILD sums follow XART-SAFETY.md. The aurora-sep and aurora-sep-slow suites pass 42 of 43, the same as #486's head; test_desktop_fixes.py needs a commit a shallow clone lacks.

2. Window lifetime. Done as you suggested, with one exception that the hardware decided.

  • Only under Pin. The guard decides in Guard::end_create. Warm-attach Macs close the window right after the create exchange, as in soc: apple: sep: Let a cold-boot Mac's owner pin the one shared xART locker #486, and a KUnit test drives that decision.
  • Every failed provisioning exit closes it, through a drop guard. So does a register_bio failure, since no activation can follow.
  • Close right after sks_recover: tried on the J313, and it fails. The LOAD_KEYBAG reply came at 12.386 s, and the enclave's rewrite of the third locker (5700cc64) at 12.662 s, during the activation's next requests. The window was shut, the guard refused it, and the enclave stopped answering (DEVICE_STATE_TRANSITION, ref-key unlock, sensor registration). So the window is held until activate_touchid returns. Its drop guard closes it on every earlier exit too.
  • Still open: a bio_open that fails before reaching activate_touchid leaves the window open until the boot ends. That case is documented, and it only pins lockers the enclave read.

3. Third pin only in the provisioning boot. Kept as a louder log with a recovery. Once the window is closed with free pins, a refused read locker logs:

  • the window is spent, with N of 3 lockers pinned, so the rewrite stays refused;
  • the reset with --force, then removing the list, which the reset keeps, and what that costs.

It fires only at level 1, for a write. It does not guess the cause: on a healthy one-pin Mac it would only fire on a refusal that is real anyway. omarchy-mac (#162) now does that set-aside itself for a setup that failed for good.

4. #486's two findings.

  • A list whose read fails partway now counts for nothing: no pins, no owned records, no spent window.
  • A pinned locker is never adopted as Linux's, even when absent at probe. When recreated and read, it can be rewritten, but never listed or deleted.

Both have KUnit tests that failed on the J313 before the fix (39 of 41) and pass after.

5. Telling this kernel apart. The parameter is now xart_guard_pins. modinfo -p apple_sep shows it, and #486's xart_guard_pin doesn't match the anchored name. #162 offers Touch ID on the J313 only when it's there; a built-in driver lists no parameters and is refused too.

Smaller. The module, FirstSetup, Setup::Pin, ABI and XART-SAFETY.md docs describe up to three lockers and the window's real span, scoped to the one J313 run. SetupWindow.open now carries the create's real result. A pin past the third is logged as such, not as an unreadable entry.

malik-na and others added 9 commits November 20, 2026 00:01
…ation

On a MacBook Air M1 (J313, 13.5 sepOS), the pre-Linux lockers are not
rewritten by CREATE_KEYBAG. Two are rewritten by the COPY_KEYBAG of the new
bag that follows it, and one by the first activation's LOAD_KEYBAG. With the
window closed straight after the create exchange, the guard refused the first
of them (tag da70de89, read this boot), COPY_KEYBAG failed, and so did
provisioning.

Leave the window open when provisioning returns, and close it when the first
activate_touchid() returns. A SetupWindow drop guard closes it on every path.
The window still opens at most once per install, on an empty list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Naeem Malik <malik2015naeem@gmail.com>
On a MacBook Air M1 (J313, 13.5 sepOS) the first Touch ID setup rewrites
three pre-Linux kind-4 lockers, all read since probe: two at COPY_KEYBAG
(tags da70de89, 140a890d) and one at the first activation's LOAD_KEYBAG
(5700cc64). All three are in a copy of the iBoot System Container taken
before Linux's first xART write. With one pin the second was refused; with
two, the third, after which the enclave stopped answering for the boot.

Hold up to three pins (MAX_PINS). Each still needs an enclave read since
probe, is never deleted and is never listed as Linux's; the window closes
once all three are used or the first activation returns. A fourth read locker
stays refused. Messages, the parameter's help, the KUnit tests and
XART-SAFETY.md say so.

With this and the previous commit, on the J313: provisioned, three pins,
xart_guard_refusals 0, enrol, 3/3 matches; after a reboot the enrolment is
restored, 2/2 matches, refusals 0, 15 of 16 session records still protected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Naeem Malik <malik2015naeem@gmail.com>
…d an absent locker

Two cases from the review of #486 (matthetherington) and #506 (scottjones),
as KUnit tests through check():

- A list whose read fails partway is reported as not loaded, but the pin
  and the owned record parsed before the failure still count: the pinned
  locker and the listed record can be rewritten.
- A pin saved for a locker that is absent at probe takes the ordinary
  adoption path: the locker is listed as Linux's and can be deleted.

Both fail at this commit; the next one fixes them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Naeem Malik <malik2015naeem@gmail.com>
…locker

A list whose read fails partway left the owned records and pins parsed
before the failure in the guard, while the guard reported the list as not
loaded. Clear everything load() set when it fails, so an unreadable list
protects every existing record as the warning says.

check() classified a saved pin only through decide(), so a pinned locker
that was absent at probe was adopted as Linux's. Classify a pinned locker
that is not Linux's as refused first; the pinned allowance (read since
probe) still applies to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Naeem Malik <malik2015naeem@gmail.com>
…pins, hint the reset

From the review of #506:

- The first-setup window outlasts the create only under the pin rule
  (Setup::Pin). Without it, as on the warm-attach Macs at level 1, the
  window closes right after the create exchange, as in #486. Under the pin
  rule a SetupWindow closes it on every failed provisioning exit and hands a
  successful one to the first activation, which closes it on any exit before
  LOAD_KEYBAG and right after sks_recover() otherwise.
- The parameter is now xart_guard_pins, so `modinfo -p apple_sep` tells this
  rule (up to three lockers, create to first LOAD_KEYBAG) apart from #486's.
- When the guard refuses a locker the enclave read on an install whose
  window is spent and whose pins are not full, it logs that the first setup
  ended early and how to reset.
- The module, FirstSetup and Setup::Pin docs, XART-SAFETY.md and the
  parameter's help describe up to three lockers and the window's span; the
  aurora-sep package's checksums follow.
- The source-order test of the create follows the new window: held from the
  create, closed unless pinning, handed to the first activation, closed
  there after sks_recover().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Naeem Malik <malik2015naeem@gmail.com>
…ghten the docs

From independent checks of the previous commit:

- The guard, not sks.rs, decides whether the first-setup window outlasts
  the create (Guard::end_create): only under the pin rule. A KUnit test
  drives that decision: after end_create a warm-attach window refuses a
  locker rewrite, a pinning one still pins a read locker. The source-order
  test now also requires the window's release to be the statement right
  after sks_recover().
- If /dev/sep-bio cannot be published after provisioning, no activation can
  follow, so a pinning window is closed there.
- The reset hint fires only at level 1, for a rewrite (not a delete), once
  the window is closed and pins are free, and is worded as a possible cause.
  It names both steps: the reset and removing the list, which the reset keeps.
- The partial-list test also checks the spent window does not count; the
  absent-pin test covers a recreated and read pinned locker being rewritten
  but never listed or deleted.
- Docs and comments that still described one locker, a create-only window,
  or "only the first pin counts", or that claimed more than one J313 run,
  are corrected; doc comments displaced by the new helpers are restored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Naeem Malik <malik2015naeem@gmail.com>
…e docs to the J313 run

From independent checks of the previous commit:

- only_a_pinning_window_outlasts_the_create checked a locker that was not
  in the existing set, so the guard adopted it and the test failed on
  correct code (KUnit on a J313: "Expected guard.check(&other, true) ==
  Err(EPERM)"). It now uses an existing, read locker.
- The reset hint no longer guesses the cause: it states the window is spent
  with N of 3 lockers pinned and the rewrite stays refused, and gives the
  reset with --force (the tool refuses a working keybag otherwise), removing
  the list, and what removing it costs.
- A pin entry past the first three, or repeated, is logged as such, not as
  an unreadable entry.
- The host test also requires the window holder's end_create to call the
  guard's.
- Docs: a cold-boot Mac without the parameter gets no window; T6001/T6002
  are untested against either T6000 or T8103; when the window stays open or
  closes if the first activation does not reach LOAD_KEYBAG; matches had no
  refusal (root writes are allowed and not logged), not "only those
  records"; a later create after a reset is untested; plural pins
  throughout; claims about the pin rule scoped to the one J313 run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Naeem Malik <malik2015naeem@gmail.com>
Closing the pinning window right after sks_recover() (review suggestion,
applied in 9b5c265) failed on the J313. With the final tree booted
(7.2.11-pr506c), the LOAD_KEYBAG reply came at 12.386 s and the enclave's
rewrite of the third pre-Linux locker (tag 5700cc64) at 12.662 s, during the
activation's next requests; the window was shut, the guard refused it, and
the enclave stopped answering (DEVICE_STATE_TRANSITION, ref-key unlock,
sensor registration). The version run successfully earlier on the same Mac
(d7cbd45fe) held the window until activate_touchid() returned.

Hold it until the first activation returns; the drop guard still closes it
on every earlier exit. The comment that called LOAD_KEYBAG the last request
to rewrite a shared locker was wrong and is gone; the docs and the
source-order test follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Naeem Malik <malik2015naeem@gmail.com>
Scope the pin results to the one J313 run; say the reset hint and the
refused-locker tag are logged with the first eight refusals in a boot, and
the tag only for kind-4 lockers; plural pins where the code allows three;
the FirstSetup and open_first_setup docs give every case. No code change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Naeem Malik <malik2015naeem@gmail.com>
@malik-na
malik-na force-pushed the sep/xart-guard-pin-j313 branch from 58e20b6 to 56b08fa Compare November 19, 2026 18:31

@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, this covers everything I raised. And thanks for running the final tree on the J313. I re-read it at 56b08fa:

  • Both host tests pass. Removing end_create or the hand-off to activation makes the window test fail. Removing the close after a failed register_bio doesn't, so that one line is only covered by reading it.
  • On the warm-attach Macs the window still closes right after the create exchange, where integration/aurora closes it today, so the M3 Air and the M2s are unchanged there. Every failed provisioning exit closes it through the drop guard.
  • The open case is a provisioning boot that never reaches activate_touchid. It's limited the way XART-SAFETY.md says: only a rewrite of a kind-4 locker the enclave read that boot gets through, and only while pin slots are free. The window ends with the boot, but anything it pinned stays pinned. I'm fine with that given the new warning.
  • The spent-window warning fires where you describe, and the recovery steps match what --reset-touchid does.
  • I couldn't break either #486 fix without a test failing.
  • A module built from this head shows xart_guard_pins in modinfo -p.

Could you try two more things on the J313 if you get a chance? First, boot back into macOS after the Linux setup and check Touch ID still unlocks and still works for a purchase or password prompt there, since those three lockers predate Linux. Second, boot an older kernel once, then do a plain reboot back to this one, and check Touch ID matches again. Then the doc can say what actually happens in both cases.

One small doc ask, not blocking. XART-SAFETY.md says a kernel without pinning, or a boot without xart_guard_pins=1, refuses the pinned lockers. Your own run shows that's sharper on the J313: the enclave stops answering for that boot, so Touch ID is out until you boot this kernel with the parameter again. I'd expect nothing lasting, but nobody has tried a plain reboot after that. Saying so in the doc would help anyone who boots an older kernel.

Good from my side. I haven't run it on hardware.

@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 confirming Touch ID still works in macOS and again in Linux after rebooting back. That was the big one. Approving at 56b08fa. The older kernel round trip can be a follow-up rather than a blocker: an older kernel has no pins and the companion package change just shows a message and changes nothing there, so one run on the J313 whenever it's convenient is plenty. If you want, a line in XART-SAFETY.md about what happens on an older kernel and after the reboot back would still help, but that's optional. Really nice work on this one.

@poulguoskov

Copy link
Copy Markdown

Tested 56b08fa on a MacBook Pro 16" M1 Pro (J316s). Pinning works here. Enrolment never got past the first capture, and I think that's a separate sensor bring-up problem, not the guard.

Setup

  • J316s, system firmware 27.0, OS firmware 13.5, iBoot-8422.141.2, FileVault on in macOS. Touch ID worked in macOS before the test.
  • Kernel built from this PR's head (7.2.11-pin506+), installed next to the stock linux-aurora as an extra Limine entry. The driver is loaded by hand with xart_writes=1 provision_keybag=1 xart_guard_pins=1.
  • fprintd 1.94.5, libfprint-git 1.94.100.r10.g6f9479c.
  • I backed up the iBoot System Container before the first load.

Pinning: works

First load, on a Mac that had never run Touch ID setup under Linux:

xART guard level 1: 11 session records exist, 0 created by Linux; the other 11 are protected
xART guard: xart_guard_pins is set and no locker is pinned: this install's first Touch ID setup may pin up to three
xART: ... 170 slots, 13 live records, max revision 25417, 0 malformed, 0 duplicate, 0 repaired; writes ENABLED
[963.99] xART guard: pinned the existing SEP-xART locker the enclave rewrote during this install's first Touch ID setup (tag 74716975)
[964.73] xART guard: allowed the enclave to rewrite this install's pinned SEP-xART locker (tag 74716975)
[964.91] sks: identity keybag provisioned

xart_guard_refusals stayed at 0 through everything below. After a reboot the pin held, and LOAD_KEYBAG answered with status 0:

xART guard level 1: 12 session records exist, 1 created by Linux; the other 11 are protected
xART guard: xart_guard_pins is set: the enclave may rewrite this install's pinned SEP-xART locker (tag 74716975) once it has read it

Only one locker was pinned here, where the J313 needed three. Since enrolment failed, Touch ID's first activation never ran. If the J316s rewrites more lockers during activation, as the J313's third one did, this test hasn't reached that yet.

Enrolment: the sensor drops to state 9 on the first capture

The sensor binds and comes online (CS timing 20 ns programmed in hardware, 8000000 Hz, mode 2, diag/sensor=online, touchid=ready). Every fprintd-enroll then fails the same way. Three tries had the calibration in place, one of them right after a clean reboot:

sbio: registering sensor at bring-up stage 2
sbio: identity count 0 before CLEAR_STATE for sensor re-registration
sbio: identity count 0 after CLEAR_STATE for sensor re-registration
sbio: identity count 0 after sensor serial registration
sep sensor: data-ready IRQ 142 configured for interrupt capture
enrol: after system SELECT_CONTEXT master catacomb state 0x3
enrol: after system SELECT_CONTEXT owner catacomb state 0x3
enrol: the sensor fell to state 9 during capture 0

The capture lasted 10.1 s, 2.2 s and 8.8 s before the fault. fprintd prints one enroll-stage-passed and then enroll-unknown-error. There's no sensor patch: warning in any of these bring-ups, but a successful patch logs nothing either, so the log doesn't say whether the patch was sent.

A guess at the cause, from reading the code, not tested: after the CLEAR_STATE re-registration, registration::patch_loaded decides whether to send the patch again. On a profile without a nonce session, which includes T6000, it trusts the acknowledgement at status[8] alone and ignores state 9. apply_sensor_patch already handles a sensor that reports the patch as accepted and still asks for it ("acknowledged, but the sensor still asks for a patch"). If the M1 Pro sensor keeps a stale 0x29 acknowledgement after CLEAR_STATE, the driver would skip the patch and the capture would hit state 9. That would match what I see. The J313 uses the same rule and enrols fine, so I may be wrong. Treating state 9 as "needs patch" on T6000 too would test it. I can run a build with that change or with sensor_trace on if it helps.

I can't tell whether this is specific to #506. On the stock kernel the guard refuses the keybag create, so enrolment was never reached there.

Full logs (before and after each load, and each enrolment try) are available if you want them. The test kernel stays installed, so I can rerun anything.

@slycke

slycke commented Nov 21, 2026

Copy link
Copy Markdown

J293 hardware test passed on 56b08fae. Tested on a 13-inch MacBook Pro (M1, 2020). The device tree reports apple,j293. T8103/J313 is the driver’s shared profile label.

With xart_writes=1 provision_keybag=1 xart_guard=1 xart_guard_pins=1, fresh enrollment and matching succeeded. The fingerprint restored and matched after reboot with both manual and automatic activation. xart_guard_refusals was 0 at each check. Fingerprint unlock also worked after suspend/resume.

@scottjones

Copy link
Copy Markdown
Collaborator

Hardware evidence for this on our 7.3 port, run today in the Omarchy Mac Lab on Naeem's MacBook Air M1 (J313), with Naeem at the Mac. slycke's J293 run on 56b08fa already passed separately above, so this adds the 7.3 port on J313.

The port

#486 and #506 are ported onto the edgeC 7.3 base as port/xart-pin-7.3 (7d15e09, test kernel 7.3.0-xartpin). It's a port rather than a cherry-pick because 7.3 replaced 7.2's first-setup window with per-boot windows, so the pins are rebuilt on top of those. Two changes beyond the PR: a pin saves the previous policy value before it is written, and provisioning opens the window before it writes the intent. Naeem stays the author with his Signed-off-by and a "Ported from" note, and Poul is credited as co-developer.

What we ran

The lab baseline passed first. Naeem's Linux Touch ID state was backed up with checksums before the runs and restored after.

Boot 1 (apple_sep xart_writes=1 provision_keybag=1 xart_guard=1 xart_guard_pins=1):

  • The first Touch ID setup window stayed open until the first activation returned.
  • The enclave rewrote 3 existing kind-4 lockers, and each was pinned (1, 2, 3 of 3) with its previous value saved.
  • Identity keybag provisioned, fprintd-enroll right-index-finger gave enroll-completed, fprintd-verify gave verify-match.

Boot 2:

  • Catacombs restored and the enrollment survived the reboot.
  • The guard let the enclave rewrite this install's pinned locker, which is the documented later-boot behavior.
  • fprintd-verify gave verify-match, same identity as boot 1.

No real records were refused in either boot. The other "refused" lines in dmesg are KUnit tests with synthetic ids. macOS Touch ID still worked afterwards.

Key lines from the two runs:

[   84.691979] apple_sep: xART guard: this install's first Touch ID setup window is open until the first activation returns
[   87.440527] apple_sep 242400000.sep: sks: identity keybag provisioned
[   25.871781] m1-air-omarchy kernel: apple_sep 242400000.sep: Touch ID: restored 1 enrolled identity/identities; enrolment survived reboot

Notes for anyone testing on 7.3

  1. Rust module parameters are set-once. Setting xart_guard_pins both in modprobe.d and on the kernel command line makes apple_sep fail to load, so set it in one place:

    apple_sep: `1' invalid for parameter `xart_guard_pins'
    
  2. On 7.3, M1 needs xart_guard=1 set explicitly (the default there is 0), plus xart_guard_pins=1. That matters for s2idle: Thunderbolt display on the borrowed dcpext1 route stays dark after resume (DPTX validate times out), while HDMI holds dcpext0 #162's touchid-options.

  3. 7.3's sep-bio speaks interface 5, so libfprint-git -6 is required. With -5, fprintd logs "interface version 5, expected 4" and reports "No devices available".

  4. Testing the port on a Mac that already had a Linux enrollment re-seals that enrollment: the first setup's locker rewrites mean the pre-test owner and user catacombs no longer restore on the old kernel. macOS Touch ID is unaffected. Plan on a fresh fprintd-enroll afterwards.

The branch is at scottjones/aurora-linux xart-pin-7.3-for-naeem if anyone wants to try it.

One lab check failed in both runs: omarchy-mac-touchid-activate.service reported "matching blocked". That's its readiness check running before matching was ready, and enroll and verify both worked, so I don't read it as a fault in this PR.

Thanks Naeem for lending the Air and staying with it through both boots, and Poul for the groundwork in #486.

scottjones pushed a commit that referenced this pull request Nov 23, 2026
…ers Touch ID setup rewrites

On a Mac that cold-boots its SEP (the M1 family), the first Touch ID
setup rewrites SEP-xART lockers (kind 4) from before Linux that the
enclave reads at every attach. On a MacBook Air M1 (J313) it rewrites
three: two at the COPY_KEYBAG after the create and one during the first
activation, about 280 ms after its LOAD_KEYBAG reply. The guard refuses
them, the enclave then stops answering, and so the M1 profiles default
to xart_guard=0, which leaves every session record on the Mac open to
the enclave. The keybag creation window allows one rewrite per boot,
during the create exchange only, so it does not cover these.

Add xart_guard_pins (default 0). With xart_guard=1 xart_guard_pins=1 on
a cold-boot Mac, the install's first setup gets a window of its own. It
is recorded as used in the list before it opens, before the
unfinished-create intent counts the list, and it runs from before the
create until the first activation returns. Every failed step before
that closes it, as does a /dev/sep-bio that cannot be published. In it,
each existing kind-4 locker the enclave read since the store opened and
now rewrites is pinned, up to three: its previous value is saved in the
policy-previous file first, as for the other windows, then a pin entry
is appended to the list and flushed, then the write lands. On later
boots with the parameters set, the enclave may rewrite a pinned locker
once it has read it. A pinned locker is never deleted and never listed
as Linux's, even when absent at probe, and a list that fails to load
partway counts for nothing. While the window is open a read locker is
pinned even where the keybag creation window would have let it through
once; anything else the per-boot windows or a one-time allowance cover
still goes through, unless recording a pin fails. Without pin entries
in the list, xart_guard_pins=0 changes nothing, nor does the parameter
on a warm-attach Mac or at level 0 or 2.

Pin entries and the used-window marker are new kinds of list entry,
which a kernel without this reads as unreadable entries and ignores.

Logs name lockers by session id, as the guard's other lines do.

Tested on 7.2 (linux-aurora #506 at a71e98b) on one J313: three pins,
no refusal, enrolment, 3 of 3 matches, and 2 of 2 after a reboot. On a
J316s (M1 Pro) the same kernel pinned one locker and held it across a
reboot; enrolment there fails at the first capture with the sensor in
state 9, which this does not touch.

[Ported from omacom/linux-aurora #506 (56b08fa, which includes
#486, 5d50300) onto the 7.3 edgeC base (e50bdd5). That base
has the per-boot keybag creation and boot policy windows (15825b4,
0f3fda0), M1 at xart_guard=0 (def843b), the list opened per
access (688c134), and none of 7.2's warm-attach first-setup window,
so the pins are rebuilt on top of those: the window is for Setup::Pin
only, a pin saves the previous value before it is written, and the
cold-boot "blocked" matching rule, its diag shim call and the
aurora-sep-ready reason are dropped because edgeC no longer has them.
The provisioning order now builds the request, opens the window, then
writes the intent. KUnit tests are ported to the new check order, and a
host test checks the window's span.]

Assisted-by: LLM
Co-developed-by: Poul Guo Skov <80295985+poulguoskov@users.noreply.github.com>
Signed-off-by: Poul Guo Skov <80295985+poulguoskov@users.noreply.github.com>
Signed-off-by: Naeem Malik <malik2015naeem@gmail.com>
Assisted-by: Claude:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 7d15e09)
@acrogenesis

Copy link
Copy Markdown
Member

We tested this series on the built-in Touch ID reader of a 16-inch 2021 MacBook Pro with M1 Max (apple,j316c, apple,t6001). Enrollment completed, and a separate fprintd-verify matched the enrolled finger on the same boot. After the match, the driver reported xart_guard 1 and xart_guard_refusals 0.

We backported all ten commits through 56b08faee1, including Poul’s original pinning patch from #486, onto the Stable linux-aurora 7.2.11.aurora14-1 source at 4fdd0fc5c931. We loaded the driver with xart_writes=1 provision_keybag=1 xart_guard=1 xart_guard_pins=1.

Enroll result: enroll-completed
Verify result: verify-match (done)

The same backport passed all 136 SEP KUnit tests in the ARM lab, including all 42 xART guard tests. Verification after another reboot is still untested on this J316c build. Thanks, Naeem and Poul, for the guarded pinning work. J316c package PR and test details

@acrogenesis

Copy link
Copy Markdown
Member

Follow-up from the same physical J316c. After rebooting the M1 Max with the combined guarded Stable backport and the pre-verification registration fix, the owner verified a saved fingerprint. A fresh terminal sudo challenge also accepted a fingerprint with cached credentials invalidated and password input closed. The owner confirmed Touch ID unlocked the Omarchy desktop. Package and hardware results · Verification driver fix

@alxzndr

alxzndr commented Nov 26, 2026

Copy link
Copy Markdown

J314s (MacBook Pro 14" M1 Pro, 2021): guarded Touch ID passes end to end, including after a reboot. One pin was enough here. This is the first 14" M1 Pro report I've seen; it adds J314s next to the J313, J293, J316s and J316c runs above.

Setup

Boot 1: setup, enrol, verify

xART guard level 1: 9 session records exist, 0 created by Linux; the other 9 are protected
xART guard: xart_guard_pins is set and no locker is pinned: this install's first Touch ID setup may pin up to three
xART: APFS-resolved .gl extent (base 0x4d4000); 170 slots, 11 live records, max revision 32789, 0 malformed, 0 duplicate, 0 repaired; writes ENABLED
xART guard: pinned the existing SEP-xART locker the enclave rewrote during this install's first Touch ID setup (tag 0cbc0065)
xART guard: allowed the enclave to rewrite this install's pinned SEP-xART locker (tag 0cbc0065)
sks: identity keybag provisioned

Boot 2: after a reboot

xART guard level 1: 10 session records exist, 1 created by Linux; the other 9 are protected
xART guard: xart_guard_pins is set: the enclave may rewrite this install's pinned SEP-xART locker (tag 0cbc0065) once it has read it
sbio: restore master catacomb state Some(1) outcome Restored
sbio: restore owner catacomb state Some(1) outcome Restored
sbio: restore user catacomb state Some(1) outcome Restored
Touch ID: restored 1 enrolled identity/identities; enrolment survived reboot
xART guard: allowed the enclave to rewrite this install's pinned SEP-xART locker (tag 0cbc0065)
  • fprintd-verify: 3 of 3 verify-match. restore restored, refusals 0.

macOS afterwards

Not checked yet. I'll follow up once I've booted macOS and tried Touch ID there.

Other observations

  1. Calibration name. The J314s sensor node's firmware-name is apple/mesacal-j314s.bin. My first attempt installed the carve as apple/mesa_calibration.bin by mistake, and enrolment failed: calibration blob apple/mesacal-j314s.bin could not be loaded (ENOENT), three bring-up attempts, then sensor patch: no acknowledgment after 250 polls / enrol: the sensor did not come back online. Once the file was installed under the right name, enrolment succeeded on the same boot, without a restart. omarchy-mac's touchid-enable already reads firmware-name, so this only affects people loading the driver by hand.
  2. hwrng. Every load logs hwrng: survey attempt N failed (EIO) five times, then hwrng: survey failed after 5 attempts (EIO). Touch ID isn't affected.
  3. diag vs. status. matching stays unverified while verifies match, same as on the other guarded Macs.

Not tested

  • A second finger or user, deleting a print, lockout, suspend/resume
  • sudo/polkit/lock screen through PAM
  • A later CREATE_KEYBAG after a Touch ID reset under the pin
  • The 7.3 port

For omacom/omarchy-mac-pkgs#166 / #162 / #202: on this J314s the same four options as #202 (xart_writes=1 provision_keybag=1 xart_guard=1 xart_guard_pins=1) work, so J314s could join the M1 opt-in once a guarded kernel ships.

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge; no actionable defects were found.RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge; no actionable defects were found.

Summary

Adds opt-in guarded Touch ID setup for cold-boot Macs, based on the J313 run.

  • Cold-boot Touch ID setup can pin up to three shared lockers.
  • Readiness reports when a cold-boot keybag was created under the guard.

malik-na explicitly documents that the window remains open until shutdown if nothing opens /dev/sep-bio. The author also identifies driver reload limits and testing deferred for other boards, additional users, deletion, lockout, sleep, and later keybag creation.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[First keybag setup] --> B{Eligible empty list?}
  B -->|No| C[Keep normal guard rules]
  B -->|Yes| D[Save setup marker]
  D --> E[Open setup window]
  E --> F{Setup rule}
  F -->|Warm attach| G[Close after create exchange]
  F -->|Cold boot with pins| H[Save up to three read lockers]
  H --> I[Close when first activation returns]
  E -->|Provisioning fails| J[Close window]
  H -->|Device publication fails| J
Loading

Reviews (1) · Last reviewed commit: "soc: apple: sep: docs for the pin window..." · Reviewed by Greptile

@maralcbr maralcbr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @malik-na, this is careful work, and the J313 evidence (tags cross-checked against a pre-Linux copy of the iBoot System Container, and the four attempts that led to the window design) is what #486 was missing. I read it at 56b08fae. The guard itself looks right to me. Under the pin rule it only lets through writes, never deletes, of existing kind-4 lockers the enclave read this boot (xart_guard.rs:671-677, :713-716). Each pin is made durable before the write lands (:633-651), there are at most three, and a pinned locker is never adopted as Linux's (:685-689). Without the parameter a cold-boot Mac still gets no window (:162-168, :582). Warm-attach Macs still close the window straight after the create, as integration/aurora does today (sks.rs:734, xart_guard.rs:544-548). Both #486 findings are fixed and tested.

One thing before merge:

  • A refusal can be overwritten by "unverified" (diag_shim.c:500-512). sep_diag_set_matching stores the new value and then reads xart_refusals. sep_diag_xart_guard_refused increments the count and then stores "blocked". Those are a plain set/read and an RMW with no return value, which are all unordered (Documentation/atomic_t.txt:82, :167). That's the store-buffering pattern, so on arm64 the setup side can read 0 refusals while its "unverified" store lands after the refusal's "blocked". The store mutex doesn't help: xart_guard_setup_recorded() runs at sks.rs:726, after the with_store closure at :711 has released it, while refusals are counted under it in check(). The result is a non-zero xart_guard_refusals with matching "unverified", so aurora-sep-ready exits 0 (aurora-sep-ready:124-128). The window is narrow and the guard still refuses the write. But the comment at diag_shim.c:495-498 and the ABI text promise the opposite, and omacom/omarchy-mac-pkgs#162 gates on this value. The simplest fix is to have matching_show report "blocked" whenever xart_refusals is non-zero. Alternatively, smp_mb() between the store and the load in sep_diag_set_matching, plus smp_mb__after_atomic() after the atomic_inc, would fix it. So would moving xart_guard_setup_recorded() into the same with_store closure as open_first_setup(). Please reword that comment to match whichever you choose. The host test calls the updates one after another, so it can't catch this.

Smaller things:

  • Some commits in the series are unsafe on their own. 4e84a6e2 holds the window through the first activation on warm-attach Macs too, until 1c21d014 narrows it again. 860b3f30 adds KUnit tests that fail by design. For a guard in a kernel tree, I'd fold 860b3f30 into 2bc1d67a, and fold the window commits so no commit widens the warm-attach window. A squash merge would also settle it.

Nits, fine as follow-ups:

  • XART-SAFETY.md says that without the parameter "the Mac is back to refusing those lockers". Your attempt-3 run shows the J313 enclave then stays silent for the rest of that boot. A line saying so, and what a plain reboot back does, would help anyone who boots an older kernel (as @scottjones suggested).
  • The close after a failed register_bio (sbio.rs:1386) is only covered by reading the code. A source-order assertion in test_the_first_setup_window_brackets_the_create would cover it.
  • a71e98bd cites 9b5c26548 and d7cbd45fe, which aren't on the branch. Worth dropping or updating them if you fold the series.

Behaviour changes to note in the PR body

  • The sysfs matching value can now move from "blocked" to "unverified" during a boot, on a cold-boot Mac with xart_guard_pins=1. Before, it only moved towards "blocked". omacom/omarchy-mac-pkgs#162 looks like it covers the consumer side.
  • On a cold-boot Mac set up under the pin, matching reads "unverified" at probe on later boots instead of "blocked" (xart_guard.rs:238, :555-557).
  • The aurora-sep-ready message for blocked cold-boot Macs now names xart_guard_pins=1.

CI: compile, KUnit, commits and the three host-test suites pass. ci / package was still pending when I looked. The ci / result and skipped ci / boot rows come from an older run, so no boot job covers this head.

Still open, and not code issues:

  • Whether Omarchy offers xart_guard_pins=1, and on which boards, needs an explicit maintainer decision. It belongs with omacom/omarchy-mac-pkgs#162.
  • This is boot-path SEP code that changes what the enclave may write to the shared gigalocker. Before any release that turns it on, cold-boot evidence at the final head is needed on each board offered. The 7.3 port run is separate from this 7.2 head. The PR's own "Not tested" list still has a later CREATE_KEYBAG after a Touch ID reset, and a one-by-one check of macOS FileVault and keychain.

Reviewed at 56b08faee168.

— Marcelo's agent

*/
void sep_diag_set_matching(int matching)
{
atomic_set(&sep_diag.matching, matching);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This store and the atomic_read below are unordered, and so are the atomic_inc/atomic_set in sep_diag_xart_guard_refused, so a racing refusal's "blocked" can be overwritten by "unverified". Reporting "blocked" from matching_show whenever xart_refusals is non-zero would fix it without barriers.

— Marcelo's agent

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Implemented in #528, which targets this branch. The sysfs read gives the refusal counter priority over the base matching state. A regression checks that subsequent setup or verification cannot turn an observed refusal back into readiness.

Comment thread drivers/soc/apple/sep.rs
},
xart_guard_pins: u8 {
default: 0,
description: "On a Mac that cold-boots its SEP (M1 family; run on a J313 only) at xart_guard=1: 1 lets the enclave rewrite the SEP-xART lockers from before Linux (up to three, read this boot) that this install's first Touch ID setup rewrites, from the keybag creation to the first activation, then and afterwards, while every other record stays guarded; 0: that rewrite is refused",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: "from the keybag creation to the first activation, then and afterwards" is hard to parse. Suggest: "1 lets this install's first Touch ID setup pin up to three SEP-xART lockers from before Linux that the enclave read this boot and rewrites between the keybag creation and the first activation; the enclave may rewrite those lockers on later boots too. Every other record stays guarded. 0: those rewrites are refused."

— Marcelo's agent

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reworded the parameter description in #528. It now distinguishes pinning a record during setup from reusing that pin on later boots, and documents which boards can admit new pins.

@malik-na

Copy link
Copy Markdown
Member Author

Review and hardware test at 56b08fa.

Hardware

Mac Build Result
J313 / T8103 (MacBook Air M1) 56b08fa not tested on this Mac: the kernel could not be staged (ERROR: module not found: 'mt7932_fullmac')

Code review

  • major drivers/soc/apple/sks.rs:831: After a successful provisioning the pinning window is left open with nothing bounding it. It is closed only by the first activate_touchid() (first open of /dev/sep-bio) or by a failed register_bio(). If userspace never opens the device that boot, the window stays open until shutdown, and any existing kind-4 locker the enclave has read can be rewritten and durably pinned (up to three), then rewritable on every later boot. These are records shared with macOS; the only gate is "read since probe". XART-SAFETY.md admits this. The window should be closed by something the driver controls.
  • minor drivers/soc/apple/xart_guard.rs:556: guarded_setup(), and so matching, follows the window marker, not a keybag actually created under the guard. The marker is written and matching moved to "unverified" before CREATE_KEYBAG is sent. If the create or a later step fails, the marker stays. On every later boot with xart_guard_pins=1 a cold-boot Mac then reports "unverified" instead of "blocked", even with no pins and a keybag later created under xart_guard=0, whose records are not on the list. The ABI text says "whose keybag was created under the guard", which the code does not establish.
  • minor pr.md:1: The PR title names the parameter xart_guard_pin, but the code at head registers xart_guard_pins, and the description says the old name is soc: apple: sep: Let a cold-boot Mac's owner pin the one shared xART locker #486's rule that did not work on the J313. The first commit's message also still describes xart_guard_pin with one locker at the create. The title should be corrected so the merge subject matches the parameter users must set.
  • question pr.md:5: The description says this head was booted on the J313 with a full setup, enrol, match and reboot. The commit messages do not support that. a71e98b says the tree booted as 7.2.11-pr506c failed (third locker refused, enclave stopped answering), and that the successful run was an earlier version, d7cbd45fe. That commit then changes where the window closes, and no commit records a hardware run after it. Was the full sequence re-run on 56b08fa, or do the results come from d7cbd45fe? If the latter, the description should name the tree that was run.
  • question drivers/soc/apple/xart_guard.rs:94: MAX_PINS = 3 is a compiled constant taken from one run on one board (J313, 13.5 sepOS), applied to every cold-boot Mac. The PR itself says the locker count is unknown on J293, J274, J316s and J314s, and J316s was measured at one. A board needing four fails setup the way attempt 3 did (enclave stops answering); a board needing one leaves two free pins for unrelated read lockers while the window is open. The cap is also per list, not per install: the reset hint tells the owner to remove the list, which reopens the window for three new pins. Should the count be a device-tree property, or justified per platform?

CI at this head: 13 passed, 0 failed, 0 pending.

Not tested: Touch ID enrolment and matching (the lab boot does not scan a finger).

@acrogenesis

acrogenesis commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Thanks, Naeem and Marcelo. I opened #528 against this PR’s branch so you can take the fixes here and keep Poul’s and Naeem’s original commits.

The guard now closes admission when provisioning finishes. The J313 driver reopens one remaining slot only during its first activation, and closes it on every exit. The other measured boards have a one-record limit. On our M1 Max the original first-setup journal shows exactly one existing record pinned before provisioning completed. The J293 report confirms working enrollment and reboot verification but gives no count, so its existing pins are honored without allowing new ones.

The matching diagnostic now distinguishes an earlier validated pin list from a newly committed identity whose UUID was recorded under the guard. An observed refusal always reports blocked. The readiness helper, ABI documentation, and package versions follow that change. The combined tree with #525 passed 143 SEP KUnit tests and its module loaded read-only in ARM KVM.

Two details in this parent PR need your confirmation. The parameter is xart_guard_pins (plural), including in the title. Commit a71e98bd identifies the successful J313 build as d7cbd45fe; the later narrower window failed. Can you confirm whether the full J313 sequence was repeated on 56b08fae? I’ve kept the earlier Air results and our M1 Max results separate from the new code in #528.

Marcelo also flagged the intermediate commits for bisection. #528 keeps the original authorship and targets the complete #506 series. For integration, please take the reviewed final tree together so intermediate commits that leave the pin window open are never released. The new tests cover failure to register the fingerprint device. The manual first-setup and reset paths still need final-head hardware evidence on each board offered.

@malik-na

Copy link
Copy Markdown
Member Author

Closing this without merging. Thanks @maralcbr and @acrogenesis for the reviews.

Kernel work moved to aurora-silicon/linux on 17 Nov and this repo is frozen. The pin never made it over, and it doesn't fit there now. aurora-silicon/linux turned the xART guard off by default on M1 (aurora-silicon/linux#1049) and removed the xart_writes and provision_keybag parameters (aurora-silicon/linux#2591). If M1 owners there ever need the guard back on, a pin would have to be redesigned against that tree.

@malik-na malik-na closed this Nov 30, 2026
maralcbr pushed a commit that referenced this pull request Dec 2, 2026
…ers Touch ID setup rewrites

On a Mac that cold-boots its SEP (the M1 family), the first Touch ID
setup rewrites SEP-xART lockers (kind 4) from before Linux that the
enclave reads at every attach. On a MacBook Air M1 (J313) it rewrites
three: two at the COPY_KEYBAG after the create and one during the first
activation, about 280 ms after its LOAD_KEYBAG reply. The guard refuses
them, the enclave then stops answering, and so the M1 profiles default
to xart_guard=0, which leaves every session record on the Mac open to
the enclave. The keybag creation window allows one rewrite per boot,
during the create exchange only, so it does not cover these.

Add xart_guard_pins (default 0). With xart_guard=1 xart_guard_pins=1 on
a cold-boot Mac, the install's first setup gets a window of its own. It
is recorded as used in the list before it opens, before the
unfinished-create intent counts the list, and it runs from before the
create until the first activation returns. Every failed step before
that closes it, as does a /dev/sep-bio that cannot be published. In it,
each existing kind-4 locker the enclave read since the store opened and
now rewrites is pinned, up to three: its previous value is saved in the
policy-previous file first, as for the other windows, then a pin entry
is appended to the list and flushed, then the write lands. On later
boots with the parameters set, the enclave may rewrite a pinned locker
once it has read it. A pinned locker is never deleted and never listed
as Linux's, even when absent at probe, and a list that fails to load
partway counts for nothing. While the window is open a read locker is
pinned even where the keybag creation window would have let it through
once; anything else the per-boot windows or a one-time allowance cover
still goes through, unless recording a pin fails. Without pin entries
in the list, xart_guard_pins=0 changes nothing, nor does the parameter
on a warm-attach Mac or at level 0 or 2.

Pin entries and the used-window marker are new kinds of list entry,
which a kernel without this reads as unreadable entries and ignores.

Logs name lockers by session id, as the guard's other lines do.

Tested on 7.2 (linux-aurora #506 at a71e98b) on one J313: three pins,
no refusal, enrolment, 3 of 3 matches, and 2 of 2 after a reboot. On a
J316s (M1 Pro) the same kernel pinned one locker and held it across a
reboot; enrolment there fails at the first capture with the sensor in
state 9, which this does not touch.

[Ported from omacom/linux-aurora #506 (56b08fa, which includes
#486, 5d50300) onto the 7.3 edgeC base (e50bdd5). That base
has the per-boot keybag creation and boot policy windows (15825b4,
0f3fda0), M1 at xart_guard=0 (def843b), the list opened per
access (688c134), and none of 7.2's warm-attach first-setup window,
so the pins are rebuilt on top of those: the window is for Setup::Pin
only, a pin saves the previous value before it is written, and the
cold-boot "blocked" matching rule, its diag shim call and the
aurora-sep-ready reason are dropped because edgeC no longer has them.
The provisioning order now builds the request, opens the window, then
writes the intent. KUnit tests are ported to the new check order, and a
host test checks the window's span.]

Co-developed-by: Poul Guo Skov <80295985+poulguoskov@users.noreply.github.com>
Signed-off-by: Poul Guo Skov <80295985+poulguoskov@users.noreply.github.com>
Signed-off-by: Naeem Malik <malik2015naeem@gmail.com>
(cherry picked from commit 7d15e09)
maralcbr added a commit that referenced this pull request Dec 2, 2026
Follow aurora-silicon/linux main (integration/aurora no longer exists)
at 4a42f31, which brings in #3133 (T8112 DCP on firmware 27.2).

Retire, each merged upstream and in this intake:
  aurora-silicon/linux#2145 as 6f84f56
  aurora-silicon/linux#2150 as 15b1e2e
  aurora-silicon/linux#2152 as 8bd4942
  aurora-silicon/linux#2153 as a2801d4
  aurora-silicon/linux#2154 as 90d3f11
  aurora-silicon/linux#2156 as dff34de
  aurora-silicon/linux#2199 as d51160c
  aurora-silicon/linux#2147, closed in favour of #3114 (merged as
  e8d93e4, in this intake)
  j613-touchid-data-ready, superseded by aurora-silicon/linux#2678
  (merged as 3777510), which describes the same line for the J613
  and J615 in t8122-j613-j615.dtsi

Update remaining carries:
- #2146, #2148, #2149 and #2151 re-pinned to their main-merged PR heads
  (carried via merge = true).
- #2155 pinned to ad63582 (last reviewed commit before #2155
  rebased onto the post-4a42f3105002 IIO API change in #3473; adds the
  describe-by-role follow-up).
- #3490 (merged on integration/aurora-7.3 in #529) re-pinned cleanly to
  upstream 717a6ff..e6e8509, dropping the 00cbc67 rebase
  commit d98f2a8.
- #370 replaced by merged upstream
  aurora-silicon/linux#3770 (6b8d44f + 9dab09e, adding the D0
  sleep quiesce/resume fix for BCM4388 s2idle).
- #3607 now carries all three commits including KUnit tests in
  drivers/bluetooth/hci_bcm4377_test.c (present in 4a42f31).
- xart-pin-7.3 note updated (#486 open, #506 closed).

Based-on-work-by: Satya Benson <satya@benson.earth>
Signed-off-by: Marcelo Alcantara <maralc@gmail.com>
maralcbr pushed a commit that referenced this pull request Dec 2, 2026
…ers Touch ID setup rewrites

On a Mac that cold-boots its SEP (the M1 family), the first Touch ID
setup rewrites SEP-xART lockers (kind 4) from before Linux that the
enclave reads at every attach. On a MacBook Air M1 (J313) it rewrites
three: two at the COPY_KEYBAG after the create and one during the first
activation, about 280 ms after its LOAD_KEYBAG reply. The guard refuses
them, the enclave then stops answering, and so the M1 profiles default
to xart_guard=0, which leaves every session record on the Mac open to
the enclave. The keybag creation window allows one rewrite per boot,
during the create exchange only, so it does not cover these.

Add xart_guard_pins (default 0). With xart_guard=1 xart_guard_pins=1 on
a cold-boot Mac, the install's first setup gets a window of its own. It
is recorded as used in the list before it opens, before the
unfinished-create intent counts the list, and it runs from before the
create until the first activation returns. Every failed step before
that closes it, as does a /dev/sep-bio that cannot be published. In it,
each existing kind-4 locker the enclave read since the store opened and
now rewrites is pinned, up to three: its previous value is saved in the
policy-previous file first, as for the other windows, then a pin entry
is appended to the list and flushed, then the write lands. On later
boots with the parameters set, the enclave may rewrite a pinned locker
once it has read it. A pinned locker is never deleted and never listed
as Linux's, even when absent at probe, and a list that fails to load
partway counts for nothing. While the window is open a read locker is
pinned even where the keybag creation window would have let it through
once; anything else the per-boot windows or a one-time allowance cover
still goes through, unless recording a pin fails. Without pin entries
in the list, xart_guard_pins=0 changes nothing, nor does the parameter
on a warm-attach Mac or at level 0 or 2.

Pin entries and the used-window marker are new kinds of list entry,
which a kernel without this reads as unreadable entries and ignores.

Logs name lockers by session id, as the guard's other lines do.

Tested on 7.2 (linux-aurora #506 at a71e98b) on one J313: three pins,
no refusal, enrolment, 3 of 3 matches, and 2 of 2 after a reboot. On a
J316s (M1 Pro) the same kernel pinned one locker and held it across a
reboot; enrolment there fails at the first capture with the sensor in
state 9, which this does not touch.

[Ported from omacom/linux-aurora #506 (56b08fa, which includes
#486, 5d50300) onto the 7.3 edgeC base (e50bdd5). That base
has the per-boot keybag creation and boot policy windows (15825b4,
0f3fda0), M1 at xart_guard=0 (def843b), the list opened per
access (688c134), and none of 7.2's warm-attach first-setup window,
so the pins are rebuilt on top of those: the window is for Setup::Pin
only, a pin saves the previous value before it is written, and the
cold-boot "blocked" matching rule, its diag shim call and the
aurora-sep-ready reason are dropped because edgeC no longer has them.
The provisioning order now builds the request, opens the window, then
writes the intent. KUnit tests are ported to the new check order, and a
host test checks the window's span.]

Co-developed-by: Poul Guo Skov <80295985+poulguoskov@users.noreply.github.com>
Signed-off-by: Poul Guo Skov <80295985+poulguoskov@users.noreply.github.com>
Signed-off-by: Naeem Malik <malik2015naeem@gmail.com>
(cherry picked from commit 7d15e09)
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.

7 participants