Skip to content

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

Draft
RyanTheTide wants to merge 2 commits into
mainfrom
sepkeybag/per-user-keybag-capability-v2
Draft

RyanTheTide wants to merge 2 commits into
mainfrom
sepkeybag/per-user-keybag-capability-v2

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 22, 2026 •

Copy link
Copy Markdown

Replaces #1824 (same changes, commit trailers fixed, on the current integration/aurora).

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.

…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).

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
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: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Author

Review at 12e80e1 (non-author, draft). No blocker in the code: against integration/aurora the only behaviour change is that the T8112 profile now refuses per-user key bags before any request is sent. One question and some text to fix before it leaves draft.

  • Merges cleanly on integration/aurora 6748d83. Two commits, human trailers only.
  • On the base the four entry points (userbag_ioctl, user_key_create_in_bag, fde_key_create, fde_unseal) test key_store == Variant5. At the head they test per_user_keybags(), which is Variant5 && !designate_unanswered, and the flag is true on T8112 only. T8122 sets it false explicitly, so it does not inherit it through ..T8112. Net effect: T8103, T6000 and the 13.5 T6020 profile refuse as before, T8112 newly refuses, every other profile is unchanged.
  • userbag_ioctl still calls require_admin() first, and the refusal returns EOPNOTSUPP before anything is sent to the enclave, so the refused path cannot reach the condition the PR describes.
  • The identity-bag and Touch ID paths do not go through these four functions.
  • The new KUnit case covers every profile in the file.

Question:

  • designate_unanswered is a per-SoC flag taken from one board on one firmware (J415, OS firmware 26.6.2). The T8112 profile also serves J413, J493 and J473, on other firmware. Is the unanswered DESIGNATE a property of the SoC's enclave, or of that sepOS version? If it is the latter, the flag belongs with whatever distinguishes the firmware (as t6020_profile() already does for the key-store dialect), not on the SoC. A J413 or J473 row on a different firmware would answer it. Refusing is the safe direction, so this does not block.

Small points, not blocking:

  • The PR body contradicts itself: the "Fix" paragraph says the capability is true only on T8140 and the T6040 family, the next paragraph says it is derived and T6020, T8122, T8132 and T8142 offer per-user bags. Only the second matches the head. The first commit message also says the M3 enclave never answers, which the second commit withdraws. Please rewrite the body to the final state.
  • The comments in profile.rs and userbag.rs say the 13.5 key store "has no user-bag requests". soc: apple: sep: per-user key bags and user-bag keys on the 13.5 key store (M1) #2049 (stacked on the predecessor of this PR) implements them for that store and reports them working on a J293. "Not implemented here" would be accurate, and soc: apple: sep: per-user key bags and user-bag keys on the 13.5 key store (M1) #2049 will need the capability to be settable per profile again instead of derived from the variant.
  • The body's KUnit count (598 run) is the first commit's; the second commit adds a case. Please rerun and update.
  • Rows: the body lists the Neo (still succeeds), M2 and M1 Pro (refuse, no key-store loss, Touch ID intact). T8122 and T8132 are the profiles this PR explicitly leaves enabled without a measurement, and a failed DESIGNATE costs the key store for the boot; one row on each would close that.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent source review at 12e80e168565. The new predicate still lets variant 5 imply per-user bags on unverified profiles. It then applies a T8112-specific exception, which leaves the behavior dependent on the model profile and defeats the aim of using a real capability. Require positive support from the SEP interface or a hardware-described capability before offering the operation. Please also reconcile the two different support rules described in the PR body.

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