Repository navigation
soc: apple: sep: per-user key bags and user-bag keys on the 13.5 key store (M1) - #2049
cameroncooper wants to merge 7 commits into
Conversation
…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>
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. Assisted-by: LLM [Claude Code, claude-opus-5-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. Assisted-by: LLM [Claude Code, claude-opus-5-5] 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. Assisted-by: LLM [Claude Code, claude-opus-5-5] 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. Assisted-by: LLM [Claude Code, claude-opus-5-5] 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. Assisted-by: LLM [Claude Code, claude-opus-5-5] Signed-off-by: Cameron Cooper <c@meron.cc>
The 13.5 key store paths for per-user bags (create, designate, import/export, unlock, lock, password change) and for user-bag keys are in place, so turn the per_user_keybags capability on for T8103. 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. Password change is implemented but not yet run on hardware; a screen lock with a grace period stays refused on this store. T6000 and the 13.5 J414s profile are unchanged: nothing has run there. Assisted-by: LLM [Claude Code, claude-opus-5-5] Signed-off-by: Cameron Cooper <c@meron.cc>
308a412 to
03bf52b
Compare
|
Thanks for the 13.5 store backend and the J293 results. Two points:
Small one: Rows we would like on J293: a password change (old refused, new accepted, keys still sign), logout and re-login in one boot, and a user-bag key refused straight after resume. |
Stacked on #1824 (its commit is the first one here; review starts at the second).
Per-user key bags and user-bag keys are refused on the 13.5 key store of M1/M2-generation Macs. This adds that store's backend and turns
per_user_keybags(from #1824) on for T8103, where it has run on hardware. The ABI is unchanged: the sameSEP_BIO_KEYBAG_*andSEP_KEY_*requests, so userspace written for variant 5 works as is.sks_req_refkeysubstituted the identity bag for an explicitly designated user bag.refkey_target()keeps explicit user designations.sks::designate_variant()shared by the identity-bag and user-bag paths (variant 0 on 13.5, without the flags word).CHANGE_LOCK_STATEversion 0, then the designated-session transition), lock (transition, loaded-bag lock, then grace-timer fires until the store names the bag locked, about 10 s on M1, withuser_bagsnot held while waiting), logout (lock and unload), and import of a bag its designation already names. A screen lock with a grace period is refused withEOPNOTSUPP: not captured on this store.SEP_KEY_FEATURE_PASSWORDadvertised whereverper_user_keybagsallows bags.per_user_keybags: true. T6000 and the 13.5 J414s profile are unchanged.Tests
test_log_ratelimit.py,test_policy_window.py,test_enrol_admission.py,test_sep_bio_identities.py,test_refkey_seal_admission.pypass. (test_keystore_only.pyfails the same way onintegration/auroratoday; it is not in CI.)Hardware
SEP_KEYBAG_STATEis refused on 13.5 withEOPNOTSUPP, as intended.🤖 Generated with Claude Code