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 11 commits into
Conversation
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. |
|
None of the 13.5 key store user-bag backend is on 110861f. The series applies cleanly on 110861f. Its base commit came from #1824, which was replaced by #2806. #2806 derives per_user_keybags() from the key store variant and the measured DESIGNATE defect, so the 13.5 store reads false there. @cameroncooper, please restack onto #2806 and turn the T8103 enable into a key-store rule that admits the 13.5 store (review point 1), rather than a per-SoC flag. The lock-timeout handling and the info-level reply dump from the review are still open, as are the J293 rows (password change, logout and re-login, a user-bag key refused after resume). Build check of 110861f plus this change (arm64, LLVM=1, Image, dtbs and every directory it touches, Fedora config plus asahi.config): builds, no warnings in the files it touches. |
03bf52b to
22bc95d
Compare
|
Thanks. Everything from both of your comments is in this push: the review points, the J293 rows and the restack. Restack onto #2806. The stack now starts with #2806's two commits, unchanged (the same patches as its head), on today's integration/aurora; they are the same patches the stack carried as #1824's.
Nit ("log a refused reply's length and status only"): done. The 96-byte print was in the base, but the 13.5 create and change-secret replies now reach it. Rows on J293 (this stack with #2050 and #2051, 2026-11-19), with a
As you asked on #2048, the commits in this stack no longer carry the Assisted-by trailer. It's the last line of the description and of this reply instead. Assisted-by: LLM (Claude:Opus 5.5) |
…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>
22bc95d to
0455829
Compare
|
One more commit at the end of this PR, from running #2051's rows on the M5 Max: "an import of a bag still held is EBUSY". The login helper imports the saved bag at every password login and takes On J716c (variant 5) with the fix, the password reopened the bag after a bag lock and after an s2idle suspend. The variant-5 import path is from the base (before #2806), so the bug was there before this stack. I put the fix here, with the rest of the bag lifecycle. Assisted-by: LLM (Claude:Opus 5.5) |
Stacked on #2806: its two commits first, unchanged (the same patches as its head), on today's integration/aurora (which has #2048). Review starts at "keep explicit user bags in 13.5 ref-key requests".
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 with it
per_user_keybags()(from #2806) holds on both key stores, false only where the measured unanswered-DESIGNATE defect is set (T8112). 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.EACCESuntil an unlock of it succeeds, and the hold survives an unload. The host sends the timer fires because the store locks only on a fire it is sent, and on macOS the kernel sends them.EBUSYbefore a second copy is loaded, on both stores, so the login helper unlocks it instead. On variant 5 the import used to designate the second copy, the store refused (the bag was still designated), and the import answeredEACCES: a password unlock after a suspend or a bag lock left the bag locked until a logout. The 13.5 store already gotEBUSY, but only after loading the copy.SEP_KEY_FEATURE_PASSWORDadvertised whereverper_user_keybagsallows bags.per_user_keybags()is a key-store rule, not a per-SoC flag. Both key stores (Variant5,Sepos13) have the user-bag requests, so it reads!designate_unansweredfor either, and a key store added later is refused. T8103, T6000 and the T6020 13.5 profile have per-user bags; T8112 keeps them refused. Only T8103 has run on hardware.Tests
per_user_keybags_follow_the_key_store_and_the_designate_defectfor every profile;a_held_bag_stays_held_until_its_unlock. 316 of 316 SEP tests pass at the tip.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.)SEP source checkshost tests pass at every commit.Hardware
SEP_KEYBAG_STATEis refused on 13.5 withEOPNOTSUPP, as intended..userPresencekey created under the bag throughSEP_KEY_CREATE_USERand signed throughSEP_KEY_SIGN:EACCES, without a capture; after the password it signed again;EACCES;aurora-sep-userbag --lock-all), the lock screen's password failed to reopen the bag (loading the key bag ... failed: Permission denied, the import's second designate refused). With the import fix, the same password reopened it, and so did the password after an s2idle suspend.From review
per_user_keybags()from the key store, false only with a cited measured failure (T8112's unanswered DESIGNATE).userbag_lock_13(): onETIMEDOUTor any lock error the driver holds the bag locked, and the comment says why the host drives the timer.userbag_refused()logs length and status only.Assisted-by: LLM (Claude:Opus 5.5)