Repository navigation
soc: apple: sep: Let a cold-boot Mac's owner pin the one shared xART locker - #486
poulguoskov wants to merge 1 commit into
Conversation
…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>
|
Thanks for documenting the unknowns explicitly. I have a J316C/T6001 (16-inch An AI-assisted, hardware-free review of head
The second case is a synthetic defensive-policy input, not an observation The accompanying report/package contains the exact extra Rust tests, small I cannot provide the useful attach/create/match locker trace from this setup |
touchid-options now gives the J313 xart_guard_pin=1 (omacom/linux-aurora#486) in place of xart_guard=0. On the J313 the first setup rewrites three pre-Linux kind-4 lockers, two at the keybag's COPY_KEYBAG and one at the first activation's LOAD_KEYBAG; with the window held through the first activation and room for three pins, setup, enrol, match and a reboot restore pass with xart_guard_refusals 0, and the guard keeps every other macOS record. #486 as posted pins one locker around CREATE_KEYBAG only and fails on the J313; the changes it needs are reported there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I ran this on a cold-boot Mac: a MacBook Air M1 (J313) with macOS 13.5 firmware,
With the window held through the first activation and up to three pins, it works:
The logs, the evidence that the three lockers are macOS's, and the two commits are in #506. It's stacked on this PR's commit, which it keeps unchanged with your authorship. Fold them in here if you prefer. One more finding: after the guard refuses one of these rewrites mid-request, the enclave answers nothing more that boot. |
…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>
…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>
…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>
…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>
Draft, for review of the approach before anything else. Not run on
hardware: I have no Mac I can risk on it, so this needs a tester who
already runs a cold-boot Mac with
xart_guard=0, or a decision that theapproach is wrong. The patch was written with an LLM (Claude) and reviewed and
tested off-device as listed under "Evidence". Against
integration/auroraat39d5f88ab4e5.Summary
On a cold-boot Mac (M1 family), creating Linux's identity keybag rewrites one
session record from before Linux, and the xART guard refuses it. Today the only
way to use Touch ID there is
xart_guard=0, which lets the enclave rewrite ordelete every session record on the Mac in order to allow one
(XART-SAFETY.md, "Cold-boot SEP Macs rewrite a pre-Linux record";
#269).
This patch adds
xart_guard_pin(default 0). It changes nothing unless set,and has an effect only on a cold-boot Mac at guard level 1:
never get, opens for the first
CREATE_KEYBAGof an install whose list isloaded and empty. The marker is written first, as on warm-attach Macs. An
earlier guarded attempt leaves the list non-empty, and the driver says so at
probe instead of promising a pin.
existing kind-4 locker, and only of a locker the enclave read since probe
(
xarm.rsnow tells the guard about eachOP_SESSION_READit answers witha record). Before the write reaches the gigalocker, a pin entry naming that
locker is appended to the list and flushed. If the pin can't be made
durable, the rewrite is refused.
any later boot where the parameter is set and it has read the locker. That
is meant to cover a match and a later
CREATE_KEYBAGafter a Touch ID reset.never listed as Linux's. Every other record from before Linux is refused as
before. Level 2 gets none of this, and without the parameter the pin in the
list is not honoured.
matchingfollows. The record the create adds is listed as on anyguarded Mac, so on a cold-boot Mac set up this way
matchingreadsunverifiedinstead ofblocked. A new shim call updates it withoutclearing the refusal count.
the pinned locker, and of any kind-4 locker it refuses under the parameter
together with whether the enclave had read it. The session id itself is
never logged.
The pin is a new kind of list entry (flag in byte 5, which owned entries keep
zero). A kernel without this patch reads it as one unreadable entry, warns,
and ignores it.
The guard no longer has a default first-setup rule.
Guard::newtakes theplatform's rule, and
sep.rsderives it from the bootstrap and the parameter,so a caller cannot get the warm-attach window by leaving something out.
sks.rsasks the guard for the window on every platform and the guarddecides.
Why this shape
one rewrite, once per install. The T6000 ledger in XART-SAFETY.md shows one
verify rewriting two session records that existed before it. If one of them
is the shared locker, a one-off window produces a keybag that can never
match.
that locker. That is the same open question as with
xart_guard=0; the pinnarrows which records Linux can change, not what a change to this one does.
Flipping a profile default is a later decision that needs macOS-side
evidence.
apple_sep: J613 (M3 Air) Touch ID blocked on every boot after one macOS boot: xART guard refuses the kind-4 rewrite, DESIGNATE_KEYBAG times out #396 uses, and it keeps the enclave from replacing a
locker it never loaded on this boot.
Not addressed: the intermittent sensor attach failures on J316s
(#42), and Macs whose keybag was already created with the
guard off (their records are not on the list; they need a Touch ID reset with
the list removed, or
xart_guard=0as today).Evidence
All of it is off-device.
tools/aurora-ci/aurora.kunitconfig(APPLE_SEP=y,APPLE_SEP_KUNIT_TEST=y), LLVM 23.1.3, Rust 1.85.0, bindgen 0.72.1drivers/soc/appletools/aurora-ci/run-kunit.pyunder QEMU 11.1.2 (arm64, 16K pages), compared withkunit-expected.jsonapple_sep_xart_guardin that runapple_sep_*suites in that runxart_guard.rs(with its KUnit tests),xart_store.rsandxarm.rsbuilt with rustc 1.100, warnings denied, against stand-ins for the kernel cratexarm::service()into the realStoreandGuard, over in-memory files, across three bootsdiag_shim.c, 1 reordered call insks.rs)APPLE_SEP=m, from a running 7.2.11.aurora14 kernel) andCLIPPY=1apple-sep; Clippy reports nothing in the lines the patch changesscripts/checkpatch.plon the patchrustfmt --checkover the driver, before and aftertools/aurora-ci/host-tests.py, groupsaurora-sepandaurora-sep-slow(43 suites)test_desktop_fixes.pyfails because it reads commit05d6db, which a shallow clone lackstest_packaging(4),test_sep_ready(22),test_diag_sensor(4, buildsdiag_shim.cwith-Wall -Werror)git apply --checkon39d5f88ab4e5,git diff --checkThe KUnit run used upstream's script unchanged, loaded through a wrapper that
replaces only its two Ubuntu LLVM 18 path functions (
LLVM=1and Arch'slibclang instead). bindgen is 0.72.1 rather than the 0.71.1 CI pins, because
the kernel's
rustavailablecheck warns that bindgen before 0.72.1 is brokenwith libclang 22 and later.
The host-side harness (three small files: stand-ins for the kernel crate and
the sibling modules, and the end-to-end tests) is not in this pull request. I
can add it under
tools/or post it if it is useful.The end-to-end test builds a gigalocker image with both roots, four "attach"
lockers, one more locker and a USER-xART record, then replays the create as
XART-SAFETY.md measured it on a J316s (a root write, one new session record,
one rewrite of an attach locker) followed by a match, a reboot, and a boot
without the parameter. It checks every reply status and what is left in the
store and in the list.
Not tested
the only kind it changes.
module (a shipped kernel's config), but it only ever ran in QEMU, which has
no Secure Enclave. The new code in
sep.rs,sks.rsanddiag.rscompiledand is pinned by a source-order test, but never executed. CI with
ci:buildwould cover the package build and the boot test.
tests plus one end-to-end test say so, but
sks.rsnow always asks theguard for the window instead of checking the bootstrap itself.
pinned locker.
Assumptions the pin makes, each of which fails closed if wrong:
J314s name kind 4; the ledger doesn't give the kind. A kind-3 record is
refused and the create fails as today.
rewrites another record from before Linux, the verify is refused and the
log shows both tags.
is refused, and recovery is a Touch ID reset with the list removed.
fresh install that macOS has not booted since, it could be the pending
locker from "Fresh installs" in XART-SAFETY.md instead; the pin then goes
to the wrong locker and the create fails. Booting macOS once before the
first setup avoids it, and XART-SAFETY.md now says so.
driver reload without an enclave restart the pinned locker counts as
unread and is refused until a reboot.
A lower-risk way to get M1 evidence
Assumptions 1 to 3 and 5 could be settled without anyone running the new
mode, from a record of what the enclave asks for on a cold-boot Mac that
already uses Touch ID with
xart_guard=0. No such record has been posted, andxarm_trace=1cannot supply one today: it logs each request's opcode, lengthand status, but not which record it names. A trace line that added the kind
and the same CRC-32 tag would change nothing the enclave may do, and a log of
one attach, one keybag creation and one match could then be replayed against
the guard in the host harness. That change is not in this patch; I can send it
separately if it is wanted.
What a hardware run would need to show
On a cold-boot Mac whose macOS data is backed up, that has booted macOS at
least once since Linux was installed, starting with no Linux keybag and no
/var/lib/aurora-sep-xart-owned.bin, withoptions apple_sep xart_guard_pin=1and the defaultxart_guard:pinned the existing SEP-xART locker ... (tag X),sks: identity keybag provisioned,xart_guard_refusals0,matchingunverified.0. If a verify is refused, the two tags and "read / had not read" are the
result to report.
Touch ID: restored N, verify again.bioutil -cunchanged, Touch ID unlock, login keychainunlocked. Then back in Linux: restored, verify.
nothing else changes.
The risk on that Mac is the one XART-SAFETY.md already states for
xart_guard=0: if macOS rejects the rewritten locker, FileVault volumes maynot unlock and recovery is a DFU restore.
Merge danger
Door: two-way. Default 0 is the current behaviour for every Mac. Reverting
leaves at most a marker and a pin entry in the list, which the old code
ignores as one consumed window and one unreadable entry.
Blast radius: cold-boot Macs whose owner sets
xart_guard_pin=1. Foreveryone else: one extra call per
OP_SESSION_READthat returns at once, andsks.rsasking the guard for the window on every profile.Files
drivers/soc/apple/xart_guard.rs:Setup, the pin entry, the pinnedallowance, the read set,
guarded_setup, tests.drivers/soc/apple/xart_store.rs,xarm.rs: pass the setup rule in, reportenclave reads to the guard.
drivers/soc/apple/sep.rs: thexart_guard_pinparameter.drivers/soc/apple/sks.rs: let the guard decide whether the create gets awindow; tell
diagwhen it does.drivers/soc/apple/diag.rs,diag_shim.c,shim.h:guarded_setupas afact behind
matching;sep_diag_set_matching().Documentation/ABI/testing/sysfs-driver-apple-sep,tools/aurora-sep/XART-SAFETY.md,aurora-sep-ready(one message),PKGBUILD(the two checksums),tests/test_diag_sensor.py(three casesand a source-order test of the create).
🤖 Generated with Claude Code