Repository navigation
soc: apple: sep: let a sep-bio capture end a sep-key touch wait - #2903
Conversation
A touch-gated /dev/sep-key call holds the sensor lock while it waits for a finger, up to a minute. A verify or an enrolment that /dev/sep-bio starts in that time queues its work item behind the lock, so a login or sudo prompt gets no sensor until the key call ends. The capture of the key call was also kept alive by the queued /dev/sep-bio capture: capture_live() returned true for either owner, so SEP_KEY_CANCEL and a signal to the caller did not end the wait while a prompt was queued. Decide who the running capture belongs to in one place, touch_capture_wanted(). While a touch-gated call owns the capture it is wanted until the call is cancelled, signalled or the driver goes away, or until /dev/sep-bio has a capture of its own that has not ended. The key call holds the sensor lock, so such a capture can only be waiting for it. The call then returns EBUSY and drops the lock, and the queued work item runs. A call that finds a /dev/sep-bio capture already queued when it gets the lock returns EBUSY without starting a capture. The UAPI header lists EBUSY for this case. A match or a non-match that was already decided is reported as before. Calls with no /dev/sep-bio activity behave as before. Signed-off-by: Ryan Murray <[email protected]>
|
Non-author review of d91adf9. Verdict: no blocker. I read the code; I didn't run KUnit and have no hardware row. Checked and holding
Points
|
|
Review at d91adf9. The ownership logic is right. One security tightening and two coverage gaps.
Rows: as listed. Please add the lock-screen case: screen locked with fprintd verifying, then a touch-gated |
There was a problem hiding this comment.
Adversarial pre-PR checklist (§1–§6) review at d91adf9ae97d1f311d397a947868d3ff6854b481 (CI: 7/7 green — host-tests, kunit, rust-build, source, and all 3 DWC3/ATC builds).
Verdict: REQUEST CHANGES — the core touch_capture_wanted() ownership truth table and key_touch_run() EBUSY preemption design are clean, and commit/PR hygiene (§4, §6) passes, but two remaining sites in drivers/soc/apple/sbio.rs still use the old disjunctive key_touch_active || bio::verify_is_live logic (causing a spurious dev_err on every preemption and leaving bring-up retries unpreempted), and the §5 hardware row is still unrun.
Blocking findings
-
Spurious
dev_err_ratelimited!on every preemption / cancel (drivers/soc/apple/sbio.rs:3073-3084):- When
/dev/sep-biostarts a capture during a/dev/sep-keytouch wait,await_capture()returnsCaptureWait::Abandonbecause!self.capture_live()(sbio.rs:4338). - The
CaptureWait::Abandonarm atsbio.rs:3075still checks:instead ofif self.key_touch_active.load(Relaxed) || bio::verify_is_live(&self.bio_session.lock(), self.capture_epoch.load(Relaxed))
self.capture_live(). - Because
key_touch_activeistrue(andbio::verify_is_liveis alsotruefor a verify), every/dev/sep-biopreemption (as well asSEP_KEY_CANCELor a caller signal) logs a false kernel error:"verify: the sensor status became unreadable during the capture". That violates §5's0 new kernel errorsbar on the exact normal path this PR introduces. Replace the guard withif self.capture_live().
- When
-
verify_wanted()still uses the old disjunctive check (drivers/soc/apple/sbio.rs:2556-2560):- The commit message states ownership is decided in one place (
touch_capture_wanted()), butverify_wanted()(called bybring_sensor_online_for_verify()on nonce-session sensors during retry) still evaluates:!self.shutting_down.load(Relaxed) && ((self.key_touch_active.load(Relaxed) && !self.key_touch_cancel.load(Relaxed)) || bio::verify_is_live(&self.bio_session.lock(), self.capture_epoch.load(Relaxed)))
- It neither yields to a queued
/dev/sep-biocapture nor checkssignal_pending(), and with a/dev/sep-bioverify queued,SEP_KEY_CANCELstill fails to abort bring-up retries — the exact bug this PR fixes incapture_live(). Delegateverify_wanted()toself.capture_live().
- The commit message states ownership is decided in one place (
-
Missing §5 hardware evidence:
- As noted in
Still to run, no Touch ID Mac hardware row has been executed yet on the default command line. Before merge, record hardware evidence covering: (a) touch-gatedSEP_KEY_SIGNpreempted by anfprintdverify ->EBUSYand verify succeeds, (b) steady-state open verify (e.g., lock screen) -> immediateEBUSYwithout starting a capture, (c)SEP_KEY_CANCELwhile a verify is queued, and (d) regression check: 0 new kernel errors (which will also confirm blocker #1 is fixed), 0 SELinux denials, 0 failed units.
- As noted in
Non-blocking notes
- KUnit currently tests only the pure
touch_capture_wanted()table; adding coverage for the two newEBUSYbranches inkey_touch_run()(key.rs:1667,:1697) would pin the ioctl-level behavior. - In
include/uapi/linux/apple-sep.h, consider clarifying that callers retryingEBUSYshould back off rather than busy-spin while a continuous/dev/sep-bioverify (such as a lock screen prompt) is open, and linking the companionaurora-sep-userspacechange.
§1–§6 Checklist Summary
- §1 No model gating: Pass (no chip/board/firmware gates).
- §2 Production-ready: Blocked —
sbio.rs:3075spuriousdev_erron preemption andsbio.rs:2556staleverify_wanted()check. - §3 Safety: Pass (unchanged lock ordering:
catacomb_writer->bio_session; no hardcoded safety limits). - §4 Clean-room & attribution: Pass (human author/committer + human
Signed-off-by:only, zero AI trailers in commit,Assisted-by:in PR body). - §5 Evidence: Blocked — KUnit/W=1 pass, but 0 Touch ID Mac hardware rows run yet.
- §6 Naming: Pass.
Two places in sbio.rs still decided on their own whether the capture was wanted, with the expression capture_live() had before: - The verify capture's CaptureWait::Abandon arm logged "the sensor status became unreadable during the capture" whenever a touch-gated call was active, so a capture given up for /dev/sep-bio, cancelled or ended by a signal was reported as a sensor fault. - verify_wanted(), which bounds the bring-up retries of a verify on sensors with a nonce session, neither gave way to /dev/sep-bio nor ended on a signal to the caller, and kept retrying after SEP_KEY_CANCEL while a /dev/sep-bio verify was queued. Use capture_live() in both. The UAPI text now also says that a caller retrying after EBUSY should back off, as a /dev/sep-bio verify can stay open for a long time. Signed-off-by: Ryan Murray <[email protected]>
|
Thanks; blockers 1 and 2 were real. New commit b729c69 (no history rewrite): the verify capture's Assisted-by: LLM (Claude:Opus 5.5) |
|
Review at b729c69. b729c69 is right for what it covers.
Rows: the Touch ID a-d rows you're running, plus the lock-screen case (fprintd verifying, a touch-gated |
There was a problem hiding this comment.
Formal adversarial §1–§6 re-review at b729c69a9356ab5b7e03671f8d488f10decbc5d9 (REQUEST_CHANGES — Wave 58B code blockers resolved, 0 remaining code blockers; still blocked on owed §5 Touch ID hardware row and pending CI).
Wave 58B Fix Verification
drivers/soc/apple/sbio.rs:3073-3083(CaptureWait::Abandonspuriousdev_err): Fixed. Now checksif self.capture_live(), so a capture abandoned due to/dev/sep-biopreemption,SEP_KEY_CANCEL, or a caller signal no longer logs"verify: the sensor status became unreadable during the capture". Verifiedsbio.rs:4183(enrolmentAbandon) is/dev/sep-bio-only and unaffected.drivers/soc/apple/sbio.rs:2558-2560(verify_wanted()stale disjunctive check): Fixed. Now delegates directly to!self.shutting_down.load(Relaxed) && self.capture_live(). Audited all otherkey_touch_active/verify_is_livesites insbio.rs(:2660is the sensor-reuse guard;:2716iskey_mode) — zero remaining stale liveness checks.- UAPI backoff guidance (
include/uapi/linux/apple-sep.h:309-312): Addressed. Now explicitly tells callers to back off when retryingEBUSYsince a/dev/sep-bioverify (e.g., lock screen) can stay open for a long time.
Checklist Summary
- §1 (No model gating): Pass.
- §2 (Production-ready, no hacks): Pass — both prior
sbio.rsblockers resolved cleanly inb729c69a9356. - §3 (Safety): Pass — lock ordering (
catacomb_writer→bio_session) unchanged. - §4 (Clean-room & attribution): Pass — both commits (
d91adf9ae97d,b729c69a9356) carry human author/committer (Ryan Murray <[email protected]>) and humanSigned-off-by:only (zero AI trailers in commits); PR body includesAssisted-by:. - §5 (Evidence): Blocked — see Blockers below.
- §6 (Naming): Pass.
Remaining Blockers
- §5 (Owed Touch ID hardware row): No hardware row has been posted yet at
b729c69a9356. Owed on a Touch ID Mac on the default command line: (a) touch-gatedSEP_KEY_SIGNpreempted byfprintdverify →EBUSYand verify succeeds, (b) steady-state open verify / lock screen → immediateEBUSYwithout starting a capture and fingerprint unlock still works, (c)SEP_KEY_CANCELwhile a verify is queued, and (d) regression counts: 0 new kernel errors, 0 SELinux denials, 0 failed units. - CI pending: 2/7 green (
source,rust-build); 5/7 stillQUEUED(host-tests,kunit,DWC3/ATC×3).
Non-blocking Notes
- Ambiguous
Matched && bio_capture_live()touch: Note that insiderun_verify()(sbio.rs:2853-2871),self.key_touch_sign()/self.key_touch_after_close()execute beforekey_touch_run()inspectsoutcome(key.rs:1691). If you choose to fail closed on an ambiguous match when a/dev/sep-bioprompt has just opened, guard bothsbio.rs:2853(so the enclave sign/unseal is not invoked) andkey.rs:1691(returningEBUSY). - Adding KUnit cases exercising the two
EBUSYarms inkey_touch_run()(key.rs:1670,:1700), documenting/dev/sep-biodevice permissions wrt starvation, and linking the companionaurora-sep-userspaceEBUSYhandling PR remain helpful follow-ups.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at b729c69a9356: the code is ready; it needs only a row at this head.
Blockers: none in the code. Missing row: one Touch ID Mac at this head: a touch-gated SEP_KEY_SIGN is ended by an fprintd verify with EBUSY and the verify succeeds, and the lock screen unlocks by fingerprint as before.
Checked: no Apple material, no gates. CI green.
Superseded by the review at b729c69
|
|
Problem
A touch-gated
/dev/sep-keycall (SIGN/UNSEAL with a biometric key) holds the sensor lock (catacomb_writer) while it waits up to a minute for a finger. A Touch ID verify or enrolment that/dev/sep-biostarts in that time (fprintd for a login, sudo or lock-screen prompt) queues its work item behind that lock, so the prompt gets no sensor until the key call ends. In addition,capture_live()returned true while either owner had a live capture, so with a/dev/sep-biocapture queued,SEP_KEY_CANCELand a signal to the caller did not end the key call's wait either.Change
touch_capture_wanted(key_wait, key_ended, bio_live): while a touch-gated call owns the capture, it is wanted until the call is cancelled, signalled or the driver goes away, or until/dev/sep-biohas a capture of its own that has not ended. The key call holds the sensor lock, so such a capture can only be one waiting for it.key_touch_run(): a call that finds a/dev/sep-biocapture already pending returnsEBUSYbefore starting a capture; a capture given up for/dev/sep-biois reported asEBUSY(notEIO), the lock is dropped and the queued work item runs.EBUSYadded to the documented/dev/sep-keyerrors ("try again later").A match or a non-match that was already decided is reported as before. Calls with no
/dev/sep-bioactivity behave exactly as before. No new lock, field, timer or parameter.Testing
apple_sep_key*, arm64 under QEMU), new casea_bio_capture_takes_the_sensor_from_a_key_touch_waitcovering the decision table. 40/40 pass; with the old expression(key_wait && !key_ended) || bio_livethe new case fails (39/40).apple-sep: no new warnings.Still to run
SEP_KEY_SIGNwaiting, then an fprintd verify -> the key call returnsEBUSYand the verify gets the sensor;SEP_KEY_CANCELends a wait while a verify is queued. Plus the SEP attach/Touch ID smoke of the other SEP rows.aurora-sep-userspace) should treatEBUSYfrom/dev/sep-keyas "try again".