Skip to content

soc: apple: sep: Touch ID in each user's own domain - #2050

Draft
cameroncooper wants to merge 23 commits into
aurora-silicon:mainfrom
cameroncooper:review/sep-touchid-user-domain
Draft

cameroncooper wants to merge 23 commits into
aurora-silicon:mainfrom
cameroncooper:review/sep-touchid-user-domain

Conversation

@cameroncooper

@cameroncooper cameroncooper commented Nov 16, 2026 •

Copy link
Copy Markdown

Stacked on #2049, which starts with #2806: one linear stack on integration/aurora, #2806 → #2049 → this. Review starts at "Touch ID for user-bag keys in the user's own domain".

Why per-account domains

Today every Touch ID match on Linux runs in one shared catacomb user (SBIO_PROBE_USER_ID), and #1767 binds user-bag key ACLs to it. On macOS each user's fingers live in that user's own domain: another user's finger cannot release your keys, and your enrolments go with your bag. On the 13.5 store this is not optional either: the enclave refuses a touch-gated operation on a key under a user's bag unless the match is against that bag user's own catacomb, so a user-bag key with Touch ID cannot work at all from the shared domain.

This series routes Touch ID into the bag user's own domain while their bag is loaded and unlocked, and leaves everything else (no bag, or no account named) exactly as it is now:

  • user-bag keys: a biometric subject routes the unlock evaluation, match, lockout and template persistence to the bag's designation; each bag user's catacomb is its own file (/var/lib/apple-sep-catacomb-bag-<uid>.bin, alongside the existing ones). A password unlock prepares a password-verified Touch ID credential; only its handle is kept, and it is deleted and wiped when the bag locks or logs out, so Touch ID needs the password once after every lock, as on macOS.

  • enrolment for a v5 ENROL_START whose account's bag is loaded goes into that user's domain; a loaded but locked bag refuses (the password is needed to add a finger).

  • verify for a named account: SEP_BIO_VERIFY_ACCOUNT with a named account_uid field (the word that was reserved, same layout), advertised as SEP_BIO_INFO_VERIFY_ACCOUNT only where per_user_keybags allows bags; SEP_BIO_IFACE_VERSION stays 5 and older kernels refuse the flag with EINVAL.

  • open a bag while a fingerprint prompt waits: the bag ioctls no longer need the Touch ID session idle, so a lock screen's password and fingerprint prompts can run together. The user's catacomb is loaded once per load of their bag, before the first password makes the Touch ID credential (loading it later would invalidate that credential); if a fingerprint wait holds the sensor then, that capture is ended as a cancel ends it, with a bounded wait for it to stop.

  • list: SEP_BIO_LIST also returns the loaded accounts' identities (unlabelled). fprintd deletes every stored print a storage device's list lacks after its first failed match; without this, one miss deleted a print the next match still answered. /dev/sep-bio is root-only, so this names identities only to root.

  • variant-5 store (T8140, T6040 and its inheritors, which have per-user bags too): a designated bag is tracked under its designation, so key touches, verifies and enrolments for its user take that user's domain as on 13.5. Before this, a touch for a bag's presence key matched in the configured domain and the enclave refused the credential (status -8).

  • delete from the bag that holds a print: a print enrolled into an account's bag is never in the shared index, so SEP_BIO_DELETE reported success while the enclave kept the template. It is now deleted in that user's domain (bag unlocked, EACCES otherwise) and the bag's catacomb, the master and the lockout record are saved before success.

  • start a bag's Touch ID afresh when the enclave forgot it: a kernel without per-user bags saves the master without the bag's component. A saved bag file the loaded master no longer lists is stale; after the bag's password, Touch ID for that bag now starts with no fingerprints instead of staying off. A listed component with no file still refuses.

  • a bag user's match has its own identity proof: once every finger is in a bag, the configured user has none and the boot-time identity proof never completes. A match with a bag subject instead needs every attach step of the restore and the enclave's own list of that bag user's identities, read after the bag's catacomb loaded: none listed answers no match without a capture, and a list that cannot be read refuses (bag_identity_proof).

  • refuse an account's own fingers while its bag is not loaded: a verify or enrolment naming an account whose bag is not loaded (logged out, or not yet unlocked this boot) ran as the configured user. For an account with an enrolment of its own, the shared templates are not its fingers. It is now refused without a capture until the password, when the account's bag catacomb exists or cannot be shown absent. The file is the evidence, since a bag enrolment succeeds only once it is saved; the master's component list is not, because it also names a bag that was designated and never enrolled. An account without the file keeps the configured user.

  • a bag catacomb that loads empty: a bag user's 0x8002 load was taken as restored. On J293 one came back active with none of the bag's identities; every match then answered no match and fprintd deleted the account's records. After a bag user's 0x8002 load the enclave's list of its identities is now read: none listed warns "enrol again" and the bag stays usable for that, as for a stale file; an unreadable list fails the load.

  • Touch ID's gates per account: every match in an account's own domain (a verify naming it, or a key touch under its bag) has that account's own failed-attempt count, lockout after five misses and, once SEP_BIO_REQUIRE_PASSWORD was called this boot, wait for its own first password. A finger the enclave answers for another user is a miss for the named account and never resets its count; the enclave's own refusal locks that account. The account's bag password clears its state and no other; SEP_BIO_REARM and SEP_BIO_LOCKOUT_STATE stay the configured user's. Before this, an account verify skipped the shared gates but still fed the configured user's count. Nothing is recorded across a restart, since the bag's password after it clears the account's state anyway.

Tests

  • KUnit: list ordering and de-duplication (apple_sep_list_accounts), tracking a variant-5 designation once, finding an account's identity by its own user, the stale-bag decision, the bag identity proof, the unloaded-bag refusal, the empty cold load and the per-account gates, plus the existing suites (325 pass); every commit builds (arm64 module), with no new warnings in the SEP files.
  • test_log_ratelimit.py and the other sep-source static tests pass.

Hardware

J293 (M1), with libfprint passing the account and a PAM bag module:

  • Gates per account (2026-11-23, A's fingers in A's bag, a finger enrolled only for the configured user B): B's finger on verifies for A gave three no-matches; on the fourth the enclave refused MATCH_RESULT itself and A was locked. Further verifies for A and the lock screen's fingerprint attempt were refused without a capture; a verify for B with that finger matched; A's password re-armed A and A's finger matched again.
  • after a password unlock, one touch signed a user-presence key under the bag, and the template update was saved to the user's file; after a lock the same call was refused at once;
  • an enrolment for the account went into the bag user's domain and its finger then signed under the bag; the configured user's enrolments were unchanged;
  • an account verify with a finger enrolled only in that domain matched; after the bag locked it was refused at once; a plain verify still matched;
  • the lock screen kept matching after misses once the list included the account's identities.

On a kernel built from this stack (with #2051, 2026-11-16), through the normal lock screen:

  • the first touch after the password matched in the user's domain, after a boot and after a suspend (before the catacomb-ordering fix in "open a bag while a fingerprint prompt waits", that first touch was refused and asked for the password again);
  • two misses, then a match; no stored print was deleted;
  • after a suspend, Touch ID was refused without a capture until the password;
  • not run on this build: enrolment into the domain.

On a kernel built from this stack (with #2051, 2026-11-19), two accounts: A with its fingers in its bag, B (the configured user) in the shared domain:

  • before A's password, a verify for A was refused without a capture;
  • with A's bag unlocked: A's finger matched for A in A's domain; B's finger did not match for A; A's finger did not match for B; B's finger matched for B, in the shared domain;
  • a key touch under A's bag: a .userPresence key signed with A's finger; after the bag locked, SEP_KEY_SIGN was refused at once with EACCES, without a capture; after A's password it signed again;
  • after A logged out, the bag was locked and unloaded and a verify for A was refused (this needed a fix to the PAM helper, which counted systemd's user-manager session and so never saw the last session close);
  • an enrolment for B with A's bag not loaded went into the shared domain;
  • A's bag loaded with its fingers after a reboot, after a master save with the bag not loaded, and after such a save 30 s after a resume. The empty load seen once that morning did not come back, so the new check is covered by KUnit only;
  • found, not fixed here: fprintd checks a new enrolment for duplicates by an identify over every stored print. When all of them are A's, libfprint names A, and with A's bag locked that refusal fails B's enrolment. The fix belongs in libfprint (libfprint aurora14: match in the account's own key bag domain aurora-sep-userspace#33).

J716c (M5 Max, T6050, variant-5 store), on integration/aurora with the J716c series (#2118–#2134, #2162) and this stack with #2051, 2026-11-17/18, with libfprint naming the account:

  • before the variant-5 commit, a presence-key signature under the bag failed with -8 while a no-presence key and a password-authorized one worked; after it, a finger enrolled in the bag user's domain authorized the bag's presence keys after a password unlock;
  • fprintd enrolment went into the bag user's domain, and the lock screen matched there;
  • deleting a print enrolled into the bag (fprintd-delete -f) removed it from the enclave: the finger was refused at once, and after a reboot the enclave listed only the remaining print;
  • with every finger in the bag and none for the configured user, the lock screen matched straight after a reboot (it had refused every touch before the identity-proof commit);
  • the stale-bag case was found here (after a boot of a kernel without per-user bags) and recovered by hand before the fix; the fix itself is covered by KUnit, not yet by a reproduction on hardware.

Assisted-by: LLM (Claude:Opus 5.5)

@cameroncooper
cameroncooper force-pushed the review/sep-touchid-user-domain branch from ac1d3bc to a5d642f Compare November 16, 2026 18:45
@cameroncooper
cameroncooper force-pushed the review/sep-touchid-user-domain branch 2 times, most recently from a7e1f3e to fd8c3c5 Compare November 16, 2026 20:23
cameroncooper added a commit to cameroncooper/keychain that referenced this pull request Nov 16, 2026
Lead with what Keychain is and does, a light/dark screenshot of the
desktop app, highlights, a how-it-works diagram, an honest status table
and a short quick start. The full command-line reference moves, intact,
to docs/USAGE.md. Point the kernel driver at aurora-silicon/linux#2050.

The smoke test no longer forces a focus ring before its screenshots.

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

Copy link
Copy Markdown

Thanks, this is the right direction. Three points:

  1. drivers/soc/apple/sbio.rs run_verify(): with SEP_BIO_VERIFY_ACCOUNT, a locked bag refuses (good), but an account whose bag is not loaded falls back to the shared configured user's templates. Once an account has its own enrolment (its catacomb file exists, or the master lists its component), a verify naming that account should refuse when the bag is not loaded,. The fallback can stay for accounts with no enrolment of their own.

  2. "let a bag user's match through the configured user's identity proof": please keep an equivalent proof on the bag side, so a bag whose catacomb lists no identity after loading answers no match. A comment and a KUnit case would cover it.

  3. The stack carries a different revision of the soc: apple: sep: fail key operations when credential disposal fails #2048 commit than soc: apple: sep: fail key operations when credential disposal fails #2048 itself. Could you rebase on soc: apple: sep: fail key operations when credential disposal fails #2048's current head so it is reviewed once?

Row we would like: two accounts, A enrolled in A's bag and B in the shared domain. With A's bag unlocked, A's finger matches and B's does not. With A logged out, a verify for A is refused. A user-bag key touch after lock is refused until A's password.

@RyanTheTide

Copy link
Copy Markdown

On the question for review about account verifies and the shared gates: please keep the failed-attempt count, the lockout and the wait for the first password since boot per account for SEP_BIO_VERIFY_ACCOUNT, rather than skipping the configured user's gates. A match in another account's domain during an account verify should count as a miss for the named account, not reset its count, and the re-arm after a password should clear only the state of the account whose password was verified. Today these are single machine-wide flags (see the updated SEP_BIO_REARM comment in #2885).

@cameroncooper
cameroncooper force-pushed the review/sep-touchid-user-domain branch from 604c9d3 to d71d382 Compare November 23, 2026 16:25
@cameroncooper

Copy link
Copy Markdown
Author

Thanks. All three points are pushed, and the two-account row ran on J293.

  1. Refuse an account's own fingers while its bag is not loaded ("refuse an account's own fingers while its bag is not loaded"). A verify or an enrolment naming such an account is refused without a capture until its password. One deviation from your wording: the evidence is the account's bag catacomb (present, or not provably absent), not the master's component list. On J293 the master listed a component for an account whose bag had been designated but never enrolled, and counting it refused that account's first enrolment into the shared domain. A bag enrolment only succeeds once its file is saved, so the file is the evidence. Accounts without one keep the shared fallback. If you'd rather keep the component as well, I can, but then that account needs its password before it can enrol at all.

  2. A bag-side identity proof ("give a bag user's match its own identity proof"). A bag-subject match needs every attach step and the enclave's own list of that bag user's identities, read after its catacomb loads: none listed answers no match without a capture, and an unreadable list refuses. KUnit: a_bag_match_needs_its_own_listed_identities.

    Related, in the new last commit ("start afresh when a bag's catacomb loads empty"): on J293 a bag catacomb once answered 0x8002 and came back active with none of its identities, and fprintd then deleted the account's records. A bag user's 0x8002 load is now checked like the configured user's: none listed warns "enrol again", and the bag stays usable for that. I couldn't reproduce the empty load (master saves with the bag unloaded, and after a resume, all loaded fine), so that check has KUnit only.

  3. Rebased. soc: apple: sep: fail key operations when credential disposal fails #2048 is merged now, so the stack sits on today's integration/aurora, then soc: apple: sep: gate per-user key bags on a proven capability, not the create variant #2806's two commits unchanged, then soc: apple: sep: per-user key bags and user-bag keys on the 13.5 key store (M1) #2049. One linear stack, and soc: apple: sep: fail key operations when credential disposal fails #2048 isn't in it any more.

  4. Gates per account (your comment of the 22nd; "keep Touch ID's gates per account"). For every match in an account's own domain (a verify naming it, and a key touch under its bag), the failed-attempt count, the lockout after five misses and the wait for the first password since boot are now that account's own:

    • the account's gates are checked before the capture, and a refusal is SEP_BIO_STATUS_LOCKOUT, as for the configured user;
    • a match the enclave answers for another user is a no match, so it is a miss for the named account and never resets its count;
    • the enclave's own refusal of MATCH_RESULT locks that account;
    • the account's bag password clears its state only. SEP_BIO_REARM and SEP_BIO_LOCKOUT_STATE stay the configured user's.

    Before this, an account verify skipped the shared gates but its results still went to the configured user's count, so they could lock the configured user out or reset its count. Nothing is recorded across a restart: a match runs in an account's domain only after its bag's password this boot, which clears its state. KUnit: touch_id_gates_are_kept_per_account, each_account_waits_for_its_own_password_after_boot.

    On J293 (2026-11-23), with A's fingers in A's bag and a finger enrolled only for the configured user B:

    • B's finger on verifies for A: three no-matches in A's domain. On the fourth touch the enclave itself refused MATCH_RESULT (A's lock state gained biometry-lockout), and the driver locked A. So the enclave does apply its own limit in a bag user's domain, after three misses there; that answers the question I'd left open.
    • The next verifies for A, and the lock screen's fingerprint attempt, were refused without a capture.
    • A verify for B with that finger then matched: B's state was untouched.
    • A's password at the lock screen re-armed A, and A's finger matched again.

Two-account row (J293, A in A's bag, B in the shared domain):

  • Before A's password: a verify for A refused, no capture.
  • A's bag unlocked: A's finger matched for A (in A's domain), B's did not; A's finger did not match for B, B's matched for B.
  • A logged out: bag locked and unloaded, verify for A refused. (This needed the PAM helper fix mentioned on soc: apple: sep: per-user key bags and user-bag keys on the 13.5 key store (M1) #2049.)
  • Key touch after lock: a .userPresence key under A's bag signed with A's finger. After the bag locked, SEP_KEY_SIGN was refused at once with EACCES (no capture), and after A's password it signed again.

Found along the way, for aurora-sep-userspace#33: fprintd's duplicate check before an enrolment identifies over every stored print. When they're all A's, libfprint names A, and with A's bag locked that refusal fails B's enrolment.

Assisted-by: LLM (Claude:Opus 5.5)

RyanTheTide and others added 16 commits November 23, 2026 15:13
…he create variant

userbag_ioctl refused per-user key bags unless profile.key_store was the
variant-5 create encoding. That encoding describes how the identity key bag
is created, not whether the enclave can create a NEW per-user bag. T8112 (M2)
and T8122 (M3) are warm-register platforms whose SEP is handed over running
and shared with macOS; their identity bag uses the variant-5 form, so they
passed the Variant5 check, yet their enclave never replies to a user-bag
DESIGNATE_KEYBAG. A single unanswered DESIGNATE condemns the SKS endpoint for
the rest of the boot (sks_wedged), taking the whole key store down: the log
shows "DESIGNATE_KEYBAG got no reply" followed by every later SKS request
reporting "endpoint gone for this boot".

Per-user bag create and designate are proven only on T8140 (J700) and the
T6040 (J616s / M4 Pro) enclave family. Add an explicit PlatformProfile
capability, per_user_keybags, true only on those, and gate userbag_ioctl and
the per-user-bag ref-key / FDE paths on it instead of on the create-encoding
variant. The unsupported platforms now return EOPNOTSUPP before any enclave
request, so the SKS endpoint is never wedged. Touch ID and the identity bag
are unaffected: neither uses userbag_ioctl.

The sep KUnit suite passes (598 run, 596 passed, 2 skipped, 0 failed).

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Signed-off-by: Cameron Cooper <c@meron.cc>
per_user_keybags was a list of the enclaves where a user-bag create and
designate had been run: true on T8140 and the T6040 family, false
everywhere else. That makes every enclave nobody has tried refuse, and
says nothing about why the one measured failure fails.

The user-bag requests are part of the variant-5 key store; the 13.5 key
store has no such requests. The one measured defect is the T8112 (J415)
enclave, which returns a handle for CREATE_KEYBAG and then never answers
DESIGNATE_KEYBAG, condemning the SKS endpoint for the boot. Name that
defect, designate_unanswered, set it on T8112 only, and derive
per_user_keybags() from the key store variant and that flag.

T8122 no longer inherits the flag from the T8112 profile it extends:
the unanswered DESIGNATE was measured on J415, not on an M3. T6020 on
current firmware, T8122, T8132 and T8142 therefore offer per-user key
bags; none of them has run a user-bag DESIGNATE yet. T8103, T6000 and
T6020 on the 13.5 key store keep refusing, as does T8112.

Add a KUnit case covering per_user_keybags() for every profile.

Signed-off-by: Ryan <ryan@aurorasilicon.org>
Signed-off-by: Cameron Cooper <c@meron.cc>
On the 13.5 key store, sks_req_refkey always substituted the configured
Linux user's designation for the target handle. That is right for the
identity bag's source handles, but it also redirected an explicitly
designated user bag, so a key meant for a per-user bag was made and
used under the identity bag instead.

Factor the choice into refkey_target(): source handles keep the
identity mapping, and an explicit user designation keeps its own bag.
Variant 5 is unchanged.

The KUnit cases cover the identity fallback, the user-designation
boundaries and variant 5.

Signed-off-by: Cameron Cooper <c@meron.cc>
The per-user bag path hard-coded designate variant 1 and its flags
trailer, the variant-5 form. The 13.5 key store takes variant 0 with
the body ending after the empty blob, as the identity-bag path already
sends it.

Move the variant choice into sks::designate_variant(), shared by both
paths, and encode and decode the user-bag designation with it. The
variant-5 layout is unchanged; the user-bag ioctls stay gated by
per_user_keybags.

The KUnit golden test gains a 13.5 case for the shorter body and its
reply, and checks that each store rejects the other's form.

Signed-off-by: Cameron Cooper <c@meron.cc>
The user-bag ioctls refused every request on the 13.5 key store of
M1/M2-generation Macs. Add that store's backend for create, import,
export, unlock and lock:

- create uses the generic DeviceBag constructor (version 1);
- unlock first unlocks the loaded bag with the version-0
  CHANGE_LOCK_STATE, which has no flags trailer, then runs the
  designated-session device-state transition. Neither alone lets a key
  under the bag run;
- lock runs the transition with state Locked and the loaded-bag lock,
  then sends grace-timer fires, as the Mac's kernel does, until the
  store names the bag locked. The store locks only on a fire, about
  10 s after an immediate lock on M1. The bag lock is not held while
  it waits. A screen lock with a grace period is not captured on this
  store and is refused with EOPNOTSUPP;
- import of a bag the user's designation already names (a repeated
  login) keeps that bag rather than designating it twice.

Variant 5 keeps a designation after its temporary handle is unloaded.
The 13.5 loaded-bag unlock needs the handle, so the bag stays loaded
from import or create until logout, which locks and unloads it.

Password change, state query and FDE sealing stay EOPNOTSUPP on the
13.5 store.

KUnit golden layouts cover the 13.5 create and its reply, the
loaded-bag unlock and lock, the timer fire, and the loaded-bag registry.

Signed-off-by: Cameron Cooper <c@meron.cc>
The 13.5 key store refused CHANGE with EOPNOTSUPP, so a user's bag
could not follow a password change.

Its change-secret request is version 1 of the variant-5 one, as macOS
13 sends it: client, handle, the old and new secrets, two further blobs
and two words (a u8 flag and the generation option), without variant
5's last word. Send it with the two blobs empty, the flag 0xff and the
generation option 0, as the variant-5 path does, and accept the
version-1 reply.

KUnit adds the golden layout. Not yet run on hardware.

Signed-off-by: Cameron Cooper <c@meron.cc>
CREATE_USER refused on the 13.5 key store because user_key_create_in_bag
made only variant 5's EC key type 5. The 13.5 store makes EC type 4
ref-keys, as it already does under the identity bag.

Choose the key type from the key store, and advertise
SEP_KEY_FEATURE_PASSWORD wherever per_user_keybags allows user bags.
Sign and unseal under a user bag already address the designation's
special handle on either store.

On J293, keys created under a user's bag signed with an enclave-checked
password.

Signed-off-by: Cameron Cooper <c@meron.cc>
per_user_keybags() refuses the 13.5 key store because that store had no
user-bag requests. It has them now: create, designate, import/export,
unlock, lock and password change in its own shapes (userbag_sepos13),
and user-bag keys under them. Derive the capability from the measured
DESIGNATE defect alone, so T8112 stays the only enclave that refuses.

On J293 (MacBook Pro 13-inch, M1, cold-boot SEP) the userbag ioctls
created, exported, imported, unlocked and locked (logout and suspend)
a user's bag, and user-bag keys signed with an enclave-checked
password. T6000 and T6020 on the 13.5 store send the same requests and
now offer per-user bags too; no M1 Pro/Max or 13.5-store M2 Pro/Max has
run them yet.

Signed-off-by: Cameron Cooper <c@meron.cc>
…onfirm its lock

On the 13.5 store a lock is two requests the store accepts with the bag
still usable, then grace-timer fires until the store reports the bag
locked. When that failed (a refused request, an unreadable reply, or
no lock after 15 fires), userbag_lock_13() returned an error with the
bag still unlocked in the store, and the suspend and logout locks rely
on it.

On any such failure the driver now holds the bag locked: key creation,
signing and unsealing under it are refused with EACCES until an unlock
of it succeeds. The hold outlives an unload, so a bag the logout could
not lock stays refused if it is loaded again before its password.

Also say why the host sends the timer fires: the store locks the bag
only on a fire it is sent, and on macOS the kernel sends them; nothing
else on Linux does.

Signed-off-by: Cameron Cooper <c@meron.cc>
userbag_refused() printed up to 96 bytes of a refused reply at info
level. The 13.5 store's create and change-secret replies now reach it,
and those can carry key-bag material. Print the length and the
operation status instead.

Signed-off-by: Cameron Cooper <c@meron.cc>
The login helper imports the saved bag at every password login and
takes EBUSY as "already loaded: unlock it". A bag locked for a suspend
(or open for another session) stays in user_bags, so a password unlock
after the lock imports it again.

The 13.5 store got EBUSY from LoadedBags::insert() once the second
copy was loaded. Variant 5 never got there: it designated the second
copy, the store refused (the bag was still designated), and the import
answered EACCES. On J716c (M5 Max) the password at the lock screen
then left the bag locked, and the user's Touch ID keys refused until a
logout.

Answer EBUSY before loading a copy when the driver still holds the
user's bag, on both stores. The helper then unlocks it as before.

Signed-off-by: Cameron Cooper <c@meron.cc>
A touch-gated SIGN or UNSEAL on a key under a user's bag matched the
configured user's templates. The enclave refuses such a key unless the
match is against the bag user's own catacomb, as macOS matches the
logged-in user, so the call could never succeed on the 13.5 store.

Add a biometric subject: while a touch-gated call on a user-bag key
waits, the verify path addresses the bag's designation instead of the
configured user. That covers the unlock evaluation, the match, the
lockout and template-update persistence, and the check that a matched
identity is known. Each bag user's catacomb lives in its own file,
/var/lib/apple-sep-catacomb-bag-<uid>.bin, through a new catacomb Slot.
Fixed machine components keep their existing files.

On the 13.5 store, a password unlock now also loads that user's
catacomb and makes the Touch ID preparation: an SCRD context verified
with the bag's password and found TouchIdEnrollment-satisfied. Only its
handle is kept, never the password, and it is deleted when the bag locks
or logs out. A touch-gated call on that bag's key without one is refused
with EACCES before the sensor is armed, so Touch ID needs the password
once after every lock, as on macOS. Unlock never takes user_bags while
it prepares, keeping the catacomb_writer-before-user_bags order of a
touch.

On J293: after a password unlock, one touch signed a user-presence key
under the bag (verified), and the template update was saved to the
user's file. After a lock the same call was refused at once.

Signed-off-by: Cameron Cooper <c@meron.cc>
A v5 enrolment carries the resolved Unix account, but it always went
into the configured user's domain, whose templates cannot satisfy keys
under that account's own bag.

When the account's bag is loaded on the 13.5 store, run the enrolment
with that bag user as the biometric subject:
- its first enrolment selects a context scoped to that user alone,
  proved by zero identities, and never SYSTEM, which would also
  reselect the shared master; later ones activate the component the
  unlock restored;
- BEGIN_ENROL is authorized by the credential the user's own password
  unlock prepared, not the identity bag's material;
- the user's catacomb is saved first, then any other dirty user, the
  shared master and the lockout record. Success is reported only once
  nothing is save-pending;
- the identity is not filed in the shared index, which is reconciled
  against the configured user. Matches check it against the enclave's
  list for that user.

A bag that is loaded but locked refuses the enrolment, as macOS asks
for the password to add a finger. An account with no loaded bag keeps
the configured user, as before. A password unlock now prepares the
credential for a user with no templates yet, so their first enrolment
can run.

On J293, an ENROL_START for the account completed into the bag user's
domain (two identities), saved its catacomb file, and one touch of the
new finger then signed a user-presence key under the bag. The
configured user's enrolments were unchanged.

Signed-off-by: Cameron Cooper <c@meron.cc>
SEP_BIO_VERIFY_START carried no account, so every verify matched the
built-in Linux user, even for an account whose fingers live in its own
key bag's domain.

Add SEP_BIO_VERIFY_ACCOUNT. With it, the request's account_uid (the
word that was reserved) is the resolved Unix account:
- while that account's bag is loaded and unlocked by its password, the
  match runs in that user's own domain, and the configured user's
  after-boot and lockout gates do not apply;
- while it is loaded but locked, the verify fails without a capture
  with the lockout status, so pam_fprintd asks for the password;
- with no loaded bag, the built-in user matches as before.

The after-boot and lockout gates track the configured user: an
account's own domain is used only once that account's bag has been
unlocked by its password since boot, which the after-boot gate asks
for, and the lockout record kept here is the configured user's.

A verify that names an account is not short-circuited by the configured
user's empty index. Where per_user_keybags allows user bags, GET_INFO
advertises the flag in reserved[0] (SEP_BIO_INFO_VERIFY_ACCOUNT);
elsewhere the flag is refused with EINVAL. The interface version stays 5, so
existing libfprint keeps working, and older kernels refuse the flag with
EINVAL.

On J293, an account verify with a finger enrolled only in that user's
domain matched; after the bag locked it was refused at once with status
8; a plain verify with a configured finger still matched.

Signed-off-by: Cameron Cooper <c@meron.cc>
A lock screen runs its password and fingerprint prompts at once. While
fprintd waited for a finger, the user-bag ioctls refused everything but
STATE with EBUSY. A password unlock would also have waited on the
waiting verify's catacomb_writer to load the user's catacomb. So a
password at the lock screen created a bag that could not then be
exported or unlocked.

Create, import, export, unlock and lock do not touch the Touch ID
session, so they no longer require it to be idle; password change and
FDE sealing still do.

The user's catacomb is loaded once per load of their bag. Loading it
resets the enclave's biometry lockout for that user, which invalidates
a Touch ID credential made before it, so the first password after the
bag loads loads the catacomb before making the credential. If a
fingerprint wait holds catacomb_writer then, that capture is ended as a
cancel ends it (fprintd sees a failure it may retry), and the lock is
awaited for at most WORKER_EXIT_WAIT_MS. A key's touch is not ended.
Without this, the first touch at a lock screen after boot found the
credential stale and needed the password again.

Every accepted password renews the credential. One that is replaced or
ends is deleted in the enclave and its handle wiped.

Signed-off-by: Cameron Cooper <c@meron.cc>
A verify naming a Unix account matches in that account's own key bag,
but SEP_BIO_LIST returned only the shared Linux index. fprintd treats a
storage device's list as complete: after the first failed match it
deletes every stored print the list lacks, so a single miss deleted the
prints of fingers enrolled in an account's domain, which the next match
still answered and fprintd could no longer place.

List the identities of every account bag the enclave holds after the
index's, once each and without a label (fprintd compares identities).
The enclave is queried outside the session and index locks, as the
live-count query is. The list now names every loaded account's
identities to whoever opens /dev/sep-bio, which is root-only.

KUnit covers the ordering and deduplication. On J293, the lock screen
kept matching a finger enrolled in the user's domain after misses.

Signed-off-by: Cameron Cooper <c@meron.cc>
…tore

The variant-5 key store (T8140, T6040 and its inheritors) has per-user
bags too, but Touch ID followed them only on the 13.5 store. Variant 5
unloads a bag once it is designated, so the bag never entered
`user_bags`: a touch for one of its user-presence keys matched in the
configured owner domain, and the enclave refused that credential for
the key (status -8). Password authorization was unaffected.

Track a designated variant-5 bag under its designation at create and
import, prepare its Touch ID after each password unlock, end the
preparation at every lock (with or without a grace period) and drop the
entry at logout. Enrolments, verifies and key touches for the bag's
user then take that user's own domain, as on 13.5; the gates follow
the profile's per-user bags instead of the 13.5 store.

KUnit covers tracking a designation once. On J716c (T6050), a
fingerprint enrolled in the bag user's domain authorized the bag's
presence keys after a password unlock.

Signed-off-by: Cameron Cooper <c@meron.cc>
A print enrolled into a Unix account's own key bag is filed in that
user's domain and never in the shared index. SEP_BIO_DELETE looked only
at the index, so deleting one reported success ("nothing to delete")
while the enclave kept the template, and the finger went on unlocking
the bag's keys and the lock screen.

When the identity is not in the index but the enclave lists it under an
account's bag, delete it there: the bag must be unlocked by its password
(its catacomb loaded), as for an enrolment into it; 0x57 names that
user's identity as the enclave lists it, and that user's catacomb, any
other dirty one, the master and the lockout record are saved before
success is reported. A locked bag refuses with EACCES; a busy session
with EBUSY; writes off with EROFS, as for any deletion.

KUnit covers finding an account's identity by its own user.

Signed-off-by: Cameron Cooper <c@meron.cc>
…ave forgot it

A bag user's catacomb is saved in its own file, and the shared master
records its component. A kernel without per-user bags restores and
saves the master without that component, so after one boot of it the
loaded master lists nothing for the bag user while the file remains.
The bag's restore treated that as a failure, and Touch ID for the bag
stayed off: verifies and keys were refused and no finger could be
enrolled again.

Decide from what the enclave lists: a listed component is loaded as
before (a missing file is refused, with what to do); neither component
nor file is a bag that never enrolled; a file the loaded master no
longer lists is stale, so the bag starts with no fingerprints and the
next enrolment replaces the file. Without a loaded master nothing
proves that, and the restore refuses as before. The restore runs only
after the bag's password, so starting afresh admits no finger; it costs
the owner their enrolled ones.

KUnit covers the decision. On J716c (T6050), after a boot of a kernel
without per-user bags left the master without the bag's component,
enrolment into the bag had been refused.

Signed-off-by: Cameron Cooper <c@meron.cc>
Matching waits at each boot for proof that the cold restore worked: the
configured Linux user's templates must list at least one identity,
because zero after a restore cannot be told from a restore that
silently failed. Once every fingerprint is enrolled into a Unix
account's own key bag, the configured user has none, the proof never
completes, and every verify and key touch was refused before the
capture, the bag's own fingers included.

A match in a bag user's own domain does not use the configured user's
templates, so give it the equivalent proof on the bag side instead
(bag_identity_proof): every attach step of the restore succeeded (the
cold-match preparation, the SCRD credential and the component restore),
and the enclave lists the bag user's identities, read after the bag's
catacomb loaded. A bag listing none answers no match without a
capture; a list the enclave does not give is refused as unproven, as
the configured user's is. A match as the configured user still needs
the full proof.

On J716c (T6050), with both fingers enrolled into the bag and none for
the configured user, the lock screen refused every touch after a
reboot.

Signed-off-by: Cameron Cooper <c@meron.cc>
… loaded

A verify or an enrolment naming a Unix account whose bag is not loaded
(logged out, or not yet unlocked this boot) ran as the configured
user: a verify matched against the shared templates, and an enrolment
went into the shared domain. That is right for an account that never
enrolled a finger of its own. For one that did, the shared templates
are not its fingers, and a match there would let another user's finger
answer for it, or a finger the account deleted from its bag.

Refuse such a request while the bag is not loaded once the account has
an enrolment of its own: its saved bag catacomb exists, or cannot be
shown to be absent. An enrolment into a bag succeeds only once that file
is saved, so the file is the evidence. The master's component list is
not: it names a bag that was designated but never enrolled as well. An
account without the file keeps the configured user, as before per-user
bags.

Signed-off-by: Cameron Cooper <c@meron.cc>
A bag user's catacomb load that answered the cold-transition status
(0x8002) was taken as restored. On J293 one such load came back active
with none of the bag's identities: the bag looked loaded, every match
in it answered no match, and fprintd deleted the account's host records
as unknown to the device. The configured user's 0x8002 load already
needs a live identity count; a bag user's did not.

After a bag user's 0x8002 load, ask the enclave for the bag's
identities. None listed is an empty load: say so, with "enrol again",
and keep the bag usable as for a stale file, so the owner can enrol
again in it. A list that cannot be read is a failed load.

Signed-off-by: Cameron Cooper <c@meron.cc>
An account verify skipped the configured user's after-boot and lockout
gates, but its result still went to the configured user's count: a miss
in an account's own domain counted towards the machine-wide lockout,
and a match there reset it. A password re-armed only the machine-wide
state.

Keep the failed-attempt count, the lockout after VERIFY_RETRY_LIMIT
misses and the wait for the first password since boot per account,
for every match that runs in an account's own domain (a verify naming
it, or a key touch under its bag):

- the account's gates are checked before the capture, and a refusal is
  SEP_BIO_STATUS_LOCKOUT, as for the configured user;
- a definitive result counts for that account alone. The enclave
  answers a finger enrolled only for another user as another user, and
  that is a no match, so it is a miss for the named account and never
  resets its count;
- the enclave's own refusal of MATCH_RESULT locks that account;
- once SEP_BIO_REQUIRE_PASSWORD was called this boot, each account
  also waits for its own password;
- the account's bag password, once the enclave accepts it, clears its
  state and no other. SEP_BIO_REARM and SEP_BIO_LOCKOUT_STATE stay the
  configured user's.

Nothing is recorded across a restart: a match runs in an account's
domain only after its bag's password this boot, which clears its state
anyway.

Signed-off-by: Cameron Cooper <c@meron.cc>
@cameroncooper
cameroncooper force-pushed the review/sep-touchid-user-domain branch from d71d382 to 1777262 Compare November 23, 2026 21:14
@cameroncooper

Copy link
Copy Markdown
Author

A fix for CI: the SEP source checks host test test_identity_preservation.py failed from "start afresh when a bag's catacomb loads empty" on, because its stubs lacked the new LoadedEmpty outcome and bag_cold_load. The fix is folded into that commit, and the source checks now pass at every commit of the stack; the kernel code is unchanged. The stack also moved onto #2049's new last commit (see my comment there).

Assisted-by: LLM (Claude:Opus 5.5)

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