Skip to content

soc: apple: sep: gate per-user key bags on a proven capability, not the create variant - #1824

Closed
RyanTheTide wants to merge 2 commits into
integration/aurorafrom
sepkeybag/per-user-keybag-capability
Closed

RyanTheTide wants to merge 2 commits into
integration/aurorafrom
sepkeybag/per-user-keybag-capability

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem

userbag_ioctl allowed per-user key bags whenever profile.key_store == Variant5. That field records the identity-bag create encoding, not whether the enclave can create a new per-user bag.

T8112 (M2) and T8122 (M3) are warm-register platforms: iBoot hands over a running SEP that is shared with macOS. Their identity bag is created with the variant-5 form, so they passed the Variant5 check — but their enclave never answers a per-user DESIGNATE_KEYBAG. One unanswered DESIGNATE condemns the SKS endpoint for the rest of the boot (sks_wedged), so the whole key store goes down. On an M2:

sks: DESIGNATE_KEYBAG got no reply after 2014 ms
sks: health check (CHANGE_LOCK_STATE) got no reply; endpoint gone for this boot
sks: health check (CREATE_KEYBAG) got no reply; endpoint gone for this boot

CREATE_KEYBAG succeeds first and returns a handle; only the DESIGNATE of that handle hangs. The path is not gated on any boot measurement or policy, so it is independent of the boot chain state.

Fix

Add an explicit PlatformProfile capability, per_user_keybags, true only where per-user bag create/designate is proven on hardware: T8140 (J700) and the T6040 (J616s / M4 Pro) enclave family. Gate userbag_ioctl and the per-user-bag ref-key / FDE paths on it instead of on the create-encoding variant.

The capability is now per_user_keybags(), derived from the variant-5 key store and a designate_unanswered flag set only on T8112, the one enclave where the unanswered DESIGNATE was measured; T6020, T8122, T8132 and T8142 have no measurement of their own and now offer per-user bags until a row says otherwise.

Unsupported platforms now return EOPNOTSUPP before any enclave request, so the SKS endpoint is never wedged. Touch ID and the identity bag are untouched: neither uses userbag_ioctl.

Test

sep KUnit suite: 598 run, 596 passed, 2 skipped, 0 failed.

Draft: still owes a hardware row — a per-user enrol still succeeds on the Neo; the M2 and M1 Pro now refuse with EOPNOTSUPP, no SKS wedge, Touch ID intact.

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>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

M2 hardware proof row — PASS

Built a proof kernel 7.3.0-aurora-sepkb1 from this branch's fix commit (455ac7a7) atop the fleet72 base (aa68b3c8) and ran it one-shot on the T8112/J415 Mac (the platform this PR actually changes).

Before (fleet72, unfixed): key_store == Variant5 passed the gate on T8112, so userbag_create issued CREATE_KEYBAG (ok) then DESIGNATE_KEYBAG, which the M2's warm macOS-shared enclave never answers → sks: DESIGNATE_KEYBAG got no reply → the whole SKS endpoint condemned for the boot ("endpoint gone for this boot"). Independently corroborated by the fleet72 qualification pass (root-path user-bag use already FAILs).

After (sepkb1, this PR): T8112 → per_user_keybags = false, so the gate refuses up front:

apple_sep 25e400000.sep: SEP platform profile: T8112/J415
apple_sep: xART guard level 1 ... key store open
KB_CREATE(/dev/sep-bio-rearm, uid 60127) -> ENOTSUP (95)
  • KB_CREATE returns EOPNOTSUPP (95) before any enclave op — no CREATE_KEYBAG, no DESIGNATE.
  • Zero DESIGNATE_KEYBAG / got no reply / endpoint gone / wedge / condemn lines in dmesg.
  • SKS stays healthy (sks: snapshot identity bound to recovered and designated bag); ran the probe 3× — every call cleanly refuses, SKS never wedges, Touch ID path unaffected.
  • 0 AVC denials, 0 oops/BUG/Call-trace, 0 failed units.

No-regression by construction (Neo T8140, M1 Pro Sepos13): this diff only changes the gate outcome on the Variant5 platforms flipped to per_user_keybags=false (T8112/M2, T8122/M3, T6020/M2Pro). On Neo the new !per_user_keybags is false exactly where the old key_store != Variant5 was false → gate passes identically; on M1 Pro (Sepos13) both are true → gate blocks identically. So the only platform whose behavior changes is M2, and that is the row proven above.

Neo (no-regression) and M1 Pro (unchanged) hardware confirmations are still owed but both Macs were unavailable this session (Neo wedged under an ORCH4 hold awaiting a power press; M1 Pro held by another lane). The proof kernel + Neo stage are built and staged for whoever runs the qualification pass.

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>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Still needed: a Neo (J700) row showing a per-user key bag enrol still succeeds on this head, then ready-marking. Both commits carry an Assisted-by trailer, so they need re-committing with a human Signed-off-by only.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Replaced by #2806: the same changes with the commit trailers fixed, on the current integration/aurora.

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.

1 participant