Repository navigation
soc: apple: sep: wipe capture buffers on rejected reads - #2888
Conversation
read_capture() wraps its receive buffer in Capture only after SPI transfer and CRC validation. A bus error after a partial or complete receive, or a checksum mismatch, frees the buffer without running Capture's wiping destructor. Construct the wiping owner before the transfer so every subsequent error return clears initialized receive bytes. Keep successful ownership and the existing allocation and input-validation behavior unchanged. Add a host regression using the production read function and destructor with synthetic SPI and allocation boundaries. All nine cases pass; the unpatched source fails the three receive-error cleanup cases. This is buffer-lifetime hardening; no information disclosure to an unprivileged caller has been demonstrated. Fixes: c1240e7 ("soc: apple: add Apple SEP driver (Touch ID and key sealing)") Signed-off-by: Matt <[email protected]>
Register tools/aurora-sep/tests/capture-error-wipe in the SEP source checks. It runs under the job's pinned Rust 1.85.0 toolchain. Signed-off-by: Matt <[email protected]>
|
Review at 471593d. Thanks for redoing this. The diff is identical to #2874, which I reviewed there (the owner is installed before SPI, so every error path wipes the buffer, and the harness has a working control). Both commits now carry only your One small thing in the description: please drop the "Generated with Claude Code" line. The |
There was a problem hiding this comment.
Adversarial pre-PR checklist (§1–§6) review at 471593d0fab73739029b3c518d286ad88e4537f6.
Verdict: REQUEST CHANGES — the code change and commit hygiene are clean, but required CI has not executed on this head (action_required) and exact-head §5 validation remains outstanding.
Code & Safety Verification
- Ownership & zeroization (
drivers/soc/apple/sensor.rs:845-875): WrappingbufinCapture(buf)immediately afterbuf.resize(len, 0xff, GFP_KERNEL)?and beforesep_sensor_xfer2()guaranteesCapture::dropruns on bothCaptureError::Bus(partial or complete SPI transfer failure) andCaptureError::Checksumearly returns, beforeKVecdeallocates the buffer. - Compiler-optimization & shim check (
sensor.rs:815-822,sensor_shim.c:863-886):Capture::dropoverwrites alllenbytes usingcore::ptr::write_volatile(b, 0)(preventing LLVM dead-store elimination), andsep_sensor_xfer2()passesrxdirectly intospi_sync_transfer()undersensor->lockwith no intermediate shim copy. The success path returns the same allocation unchanged. - Regression suite (
tools/aurora-sep/tests/capture-error-wipe/,.github/workflows/sep-source.yml): Extracts productioncrc16_ansi,Capture,Drop for Capture, andread_capture, checks fixture constants againstsensor.rs, and includes a verified 3-failure negative control against the unpatched source.
Blockers
- §5 (CI not run on
471593d0):SEP source checks(source,rust-build, arm64 QEMUkunit,dwc3-atc-compile) is currentlyconclusion=action_required(awaiting maintainer workflow approval on this fork PR, run45081870806), andHost testshas not run (check-runs: 0). Required CI must execute and pass on471593d0before approval. - §5 (Exact-head hardware / regression evidence): As noted in the PR description, full kernel/module build, KUnit execution, and a Touch ID hardware smoke + regression run (0 SELinux denials, 0 failed units, 0 new kernel errors) on this exact
integration/aurorahead (471593d0) are still outstanding (the cited M3 Air run was on an olderomacom/linux-aurora#251head9e899a873). Once CI is approved and green, please coordinate a quick Touch ID enrol/match + regression smoke row on Touch ID hardware at471593d0.
Non-blocking Nits
drivers/soc/apple/sensor.rs:815-822(pre-existing): addingcore::sync::atomic::compiler_fence(core::sync::atomic::Ordering::SeqCst)after thewrite_volatileloop inCapture::dropis good defense-in-depth against reordering across the wipe.tools/aurora-sep/tests/capture-error-wipe/run.py:280-288:function()uses a naive brace counter that does not ignore braces inside comments or string literals; fine on currentsensor.rs, just fragile if braced comments are added later.
§1–§6 Checklist Summary
- §1 No model gating: Pass.
- §2 Production-ready: Pass.
- §3 Safety: Pass —
write_volatilezeroization runs before deallocation on every post-transfer error path. - §4 Clean-room & attribution: Pass — both commits (
5907bb1b145a,471593d0fab7) carry human author/committer and humanSigned-off-by:only, with zero AI trailers in commits. - §5 Evidence: Blocked —
SEP source checks(action_required) andHost testshave not run on471593d0; exact-head CI and Touch ID HW smoke/regression row outstanding. - §6 Naming: Pass.
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 471593d0fab7: the code is ready; it needs only a row at this head.
Blockers: none in the code. Missing row: I've approved the waiting SEP source checks run; it has to pass. Then one Touch ID Mac at this head (the M3 Air you used is fine) with a rejected read wiping the capture buffer, and enrol and verify still working.
Checked: thank you. No Apple material. The capture buffers are wiped on a rejected read, and the new CI step only runs the local harness (run.py, rustc on the in-repo cases). Nit: Capture::drop could add a compiler_fence(SeqCst) after the volatile wipe.
Superseded by the review at 471593d
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Quick clarification on hardware for the On I can either build and run a Touch ID enrol/verify smoke row at exact head |
|
|
|
Yes, please run the J313 row at
|
|
J700 (MacBook Neo) reduced row at
|
What: Construct the wiping
Captureowner before starting the SPI transfer inread_capture()so bus failures and CRC rejections zero the receive buffer before freeing it, and add a host regression suite inSEP source checks.Tested:
SEP source checks(source,capture-error-wipe9/9 + 3-failure negative control,rust-build, arm64 QEMUkunit,dwc3-atc-compile) pass at471593d0fab7; exact-head Touch ID Mac hardware row still needed.Risk: two-way door · all Touch ID Macs using
apple_sepNot yet: Exact-head Touch ID Mac hardware smoke and regression row at
471593d0fab7(enrol, verify, 0 SELinux denials, 0 failed units, 0 new kernel errors).Details
read_capture()wraps its receive buffer inCaptureonly after the SPI transfer and the CRC check pass. A bus error after a partial or complete receive, or a checksum mismatch, returns early and frees aKVecholding fingerprint image bytes without runningCapture's wipingDrop. Each read allocates a fresh buffer and callers never see it on error, so this is buffer-lifetime hardening; no disclosure to an unprivileged caller has been demonstrated.Construct the
Captureowner before starting the transfer so itsDropruns on those error paths. The success path returns the same allocation. A resize failure still happens before SPI has received any image bytes, and length validation is unchanged.Changes:
drivers/soc/apple/sensor.rs: 6+/1-, constructCapture(buf)beforesep_sensor_xfer2().tools/aurora-sep/tests/capture-error-wipe/: host regression built from the productionread_capture()andCapture::drop, with synthetic SPI and allocation boundaries..github/workflows/sep-source.yml: runscapture-error-wipeinSEP source checksunder Rust 1.85.0.Port of
omacom/linux-aurora#251. The original approval recorded an M3 Air smoke test run by reviewers on the earlier test kernel (9e899a873). Applied toaurora-silicon/linuxwith no source conflicts and registered insep-source.yml.Evidence
At head
471593d0fab73739029b3c518d286ad88e4537f6:SEP source checksjobs (source,rust-build, arm64 QEMUkunit,dwc3-atc-compilex3) passed.python3 tools/aurora-sep/tests/capture-error-wipe/run.py, Rust 1.85.0): 9/9 cases pass (partial_bus_failure_wipes,complete_bus_failure_wipes,crc_rejection_wipes,success_preserves_until_owner_dropped, plus 5 boundary/allocation cases).--sourceagainst unpatched110861f43:drivers/soc/apple/sensor.rs --expect-failures 3): exactly the 3 receive-error cleanup cases fail because image bytes are freed unwiped (6 passed; 3 failed).origin/main(6f05cf2940c5d):git merge-treesucceeds with no conflicts.