Repository navigation
soc: apple: sep: latch only a key context's failed delete - #3001
cameroncooper wants to merge 2 commits into
Conversation
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist review at 1a969ee78e2a9677533a4dc58b21e650dbf586c6.
The latch-scoping logic itself is sound and resolves the #2048 blocker cleanly:
delete_unlock_evaluation()(drivers/soc/apple/sep.rs:2778) now only logs and returnsErr(EIO), so/dev/sep-bioverify paths throughclose_unlock_evaluation()(sbio.rs:723, 1282, 2754, 2867;sep.rs:2747) no longer quarantine/dev/sep-key.impl ContextDelete for SepData(drivers/soc/apple/key.rs:974) setskey_context_failedon delete failure and logs the quarantine warning;OwnedContext::dispose()(key.rs:1007) routes password-gated (key.rs:2139/2146), touch-gated (sbio.rs:2772/2866+key.rs:1679), and self-testOwnedContextpaths through it, and the direct context cleanups inkey.rsnow callself.delete_context().- §1–§6 checks pass: no model gating (§1), no hacks/params (§2), fail-closed safety semantics preserved (§3), clean human commit attribution and
Signed-off-bywithAssisted-by:in PR body (§4), KUnit + J293 hardware/regression evidence (§5), and naming (§6).
Blockers (1)
- CI failure in
SEP source checks / source(tools/aurora-sep/tests/test_key_context_cleanup.py):test_key_context_cleanup.pyextracts two slices fromdrivers/soc/apple/key.rsand compiles them standalone with hostrustc:pub(crate) trait ContextDelete..impl ContextDelete for SepData(lines 959–973), which now pulls inlatch_failed_delete(failed: &kernel::sync::atomic::Atomic<bool>, ...)(key.rs:967-972).struct Deleter {..// Production kernels do not build(lines 2544–2645), which now pulls inonly_a_failed_key_context_delete_latches()(key.rs:2636-2644).
- Standalone host
rustchas neitherkernel::sync::atomic::AtomicnorRelaxed, sotest_production_context_disposalfails to compile (E0433/E0425), breakingSEP source checks / source(https://github.com/aurora-silicon/linux/actions/runs/45216423162/job/137838678293). - Fix: Move
latch_failed_delete()outside theContextDelete..impl ContextDelete for SepDataslice (e.g., belowOwnedContextor inline inimpl ContextDelete for SepData) and moveonly_a_failed_key_context_delete_latches()below// Production kernels do not build(or updatetest_key_context_cleanup.pyif you want the host harness to exercise the latch helper with an atomic shim).
Non-blocking notes
only_a_failed_key_context_delete_latches()currently tests only the 4-linelatch_failed_delete()helper in isolation rather than testingOwnedContext+ContextDeletelatching vs.close_unlock_evaluation()not latching.- Pre-existing:
key_context_for()(key.rs:1732) still returns early via.ok_or(EIO)?on aNonetransport reply fromscrd_context_externalize(&ctx)without callingdelete_context(&ctx).
Assisted-by: LLM (Gemini 4 Neon)
delete_unlock_evaluation() set key_context_failed on any failed delete, and every /dev/sep-bio verify closes its unlock evaluation through it. One failed delete at the end of a Touch ID prompt therefore turned off /dev/sep-key until reboot, while the verify that hit it still reported its match. That evaluation authorizes no key operation. Set the latch only where a key operation's context is deleted: in SepData's ContextDelete, which OwnedContext uses (including the context a touch-gated key operation hands to the prompt), and in the key.rs paths that delete a context directly. close_unlock_evaluation() and delete_unlock_evaluation() now only log a failed delete. Signed-off-by: Cameron Cooper <c@meron.cc>
…reply key_context_for() creates a tracked context and then externalizes it. A refused externalize deleted the context, but one that got no reply returned EIO with the context still alive in the enclave, and nothing deleted it until the enclave restarted. Delete it on both: the context exists once it is created. A delete that then fails latches /dev/sep-key, as for any key context. Signed-off-by: Cameron Cooper <c@meron.cc>
1a969ee to
4fbabf6
Compare
|
Thanks for the review. Fixed in the push: Blocker ( Non-blocking notes:
The J293 row in the description ran on the previous revision; only the move and the no-reply delete have changed since. Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist re-review at 4fbabf61e49dcdbe732231f545705ad79db7af6b.
Verdict: APPROVE — the prior CI blocker and both non-blocking notes from 1a969ee7 are cleanly resolved.
Verification of Fixes Since 1a969ee7
- CI blocker (
SEP source checks / source—tools/aurora-sep/tests/test_key_context_cleanup.py): Resolved.latch_failed_delete()now sits afterimpl ContextDelete for SepData(drivers/soc/apple/key.rs:977) andonly_a_failed_key_context_delete_latches()sits below// Production kernels do not build(key.rs:2641), keeping kernel atomics out of the standalone hostrustcslices.SEP source checks / sourceis nowsuccess(alongsidehost-tests,DWC3/ATC builtin-no-atc, andDWC3/ATC modular-no-atc; remainingkunit,rust-build, andDWC3/ATC builtin-modular-atcjobs are still running/queued and must finish green before merge). - KUnit coverage:
only_a_failed_key_context_delete_latches()now drives bothOwnedContext::finish()anddrop(OwnedContext)through a latchingContextDeleteimplementation, verifying confirmed delete leaves the latch clear, failed finish/drop sets it, and a later confirmed delete preserves the latched state. - Commit 2 (
4fbabf61e49d—key_context_for()no-reply externalize cleanup): Sound. Ifscrd_context_externalize(&ctx)is refused or returnsNone(no reply),key_context_for()now deletes the already-created tracked context viaself.delete_context(&ctx)(latching if that delete fails) before returningErr(EIO), matchingpasscode_context().
Checklist Summary (§1–§6)
- §1 (No model gating): Pass — generic SEP driver change.
- §2 (Production-ready / default cmdline): Pass — no cmdline params, retries, or hacks.
- §3 (Safety): Pass — fail-closed
/dev/sep-keyquarantine is strictly preserved for all key contexts (password-gated, touch-gatedOwnedContext, self-tests, andkey_context_for()externalize failures), while non-key/dev/sep-biounlock evaluations (close_unlock_evaluation()/delete_unlock_evaluation()and failed preflight inopen_unlock_evaluation()) log without bricking/dev/sep-key. - §4 (Clean-room & attribution): Pass — both commits (
791ebdb9fad8,4fbabf61e49d) carry human author/committer (Cameron Cooper <c@meron.cc>) and humanSigned-off-by:only (zero AI trailers in commits); PR body includesAssisted-by:. - §5 (Evidence): Pass — 309/309 SEP KUnit tests pass on arm64 QEMU at each commit,
SEP source checks / sourcepasses, and J293 (M1) live hardware + regression run (1a969ee7, with only helper/test placement and thekey_context_for()None-reply error path changed since) verified password sign/unseal, 10 Touch ID unlocks,SEP_KEY_GET_INFO, 0 failed units, and 0 new kernel errors. - §6 (Naming): Pass.
Assisted-by: LLM (Gemini 4 Neon)
Follow-up to #2048, for the blocker in #2048 (comment): one failed delete of a Touch ID unlock evaluation turned off /dev/sep-key until reboot, while the verify that hit it still reported its match.
This takes the first option you gave:
key_context_failedis set only where a key operation's context is deleted, andclose_unlock_evaluation()only logs.SepData'sContextDelete(used byOwnedContext::dispose()) sets the latch on a failed delete. That includes the context a touch-gated key operation hands to the prompt (sbio.rs drops it as anOwnedContext), so that path is still covered, and the check after the job (key.rs) is unchanged.close_unlock_evaluation()(password context setup, the self-tests) now calldelete_context(), so they keep latching.delete_unlock_evaluation()andclose_unlock_evaluation()no longer touch the latch. Every /dev/sep-bio verify path (sbio.rs and the preflight in sep.rs) only logs a failed delete.Second commit
key_context_for()(the password-gated key paths and the self-tests) deleted a tracked context whose externalize was refused, but returnedEIOwith the context still alive when the externalize got no reply. It now deletes it on both, and a delete that then fails latches /dev/sep-key like any other key context. The no-reply path has not happened on hardware; a reply takes the same path as before.Tests
only_a_failed_key_context_delete_latchesdrivesOwnedContexts through a deleter that latches asSepDatadoes: a confirmed delete (finished or dropped) leaves the latch clear, a failed one sets it, and a later confirmed one leaves it set. 309 of 309 SEP tests pass on arm64 QEMU, at each of the two commits.SEP source checks / sourcetest passes, includingtest_key_context_cleanup.py.1a969ee7; since then only the helper and its test have moved, and the second commit is new) on today's integration/aurora (with the soc: apple: sep: per-user key bags and user-bag keys on the 13.5 key store (M1) #2049–soc: apple: sep: authorization contexts for user-bag keys #2051 stack): password sign and unseal of a user-bag key (SEP_KEY_SIGN_PASSWORD,SEP_KEY_SEALthenSEP_KEY_UNSEAL_PASSWORD, the secret back unchanged), then 10 Touch ID screen unlocks (10 satisfied matches), then the same password sign and unseal again: all passed.SEP_KEY_GET_INFOworked before and after; no "private key operations disabled" and no failed delete in the journal. Regression: 0 failed units; SELinux is not enabled on this install, so 0 denials; no new kernel errors (the only error lines,audit: backlog limit exceededat login, appear on earlier boots too). The failure path itself has not been forced on hardware.Assisted-by: LLM (Claude:Opus 5.5)