Skip to content

soc: apple: sep: wipe capture buffers on rejected reads - #2888

Merged
RyanTheTide merged 2 commits into
aurora-silicon:mainfrom
mmdisbrow:sep-capture-wipe-v2
Nov 27, 2026
Merged

RyanTheTide merged 2 commits into
aurora-silicon:mainfrom
mmdisbrow:sep-capture-wipe-v2

Conversation

@mmdisbrow

@mmdisbrow mmdisbrow commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What: Construct the wiping Capture owner before starting the SPI transfer in read_capture() so bus failures and CRC rejections zero the receive buffer before freeing it, and add a host regression suite in SEP source checks.
Tested: SEP source checks (source, capture-error-wipe 9/9 + 3-failure negative control, rust-build, arm64 QEMU kunit, dwc3-atc-compile) pass at 471593d0fab7; exact-head Touch ID Mac hardware row still needed.
Risk: two-way door · all Touch ID Macs using apple_sep
Not 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 in Capture only 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 a KVec holding fingerprint image bytes without running Capture's wiping Drop. 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 Capture owner before starting the transfer so its Drop runs 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-, construct Capture(buf) before sep_sensor_xfer2().
  • tools/aurora-sep/tests/capture-error-wipe/: host regression built from the production read_capture() and Capture::drop, with synthetic SPI and allocation boundaries.
  • .github/workflows/sep-source.yml: runs capture-error-wipe in SEP source checks under 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 to aurora-silicon/linux with no source conflicts and registered in sep-source.yml.

Evidence

At head 471593d0fab73739029b3c518d286ad88e4537f6:

  • CI: all 6 SEP source checks jobs (source, rust-build, arm64 QEMU kunit, dwc3-atc-compile x3) passed.
  • Local host regression (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).
  • Negative control (--source against unpatched 110861f43: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).
  • Clean merge check against origin/main (6f05cf2940c5d): git merge-tree succeeds with no conflicts.

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

Copy link
Copy Markdown
Contributor

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 Signed-off-by. Fine from my side.

One small thing in the description: please drop the "Generated with Claude Code" line. The Assisted-by: line as the last line is all that's needed.

@DjDeveloperr DjDeveloperr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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): Wrapping buf in Capture(buf) immediately after buf.resize(len, 0xff, GFP_KERNEL)? and before sep_sensor_xfer2() guarantees Capture::drop runs on both CaptureError::Bus (partial or complete SPI transfer failure) and CaptureError::Checksum early returns, before KVec deallocates the buffer.
  • Compiler-optimization & shim check (sensor.rs:815-822, sensor_shim.c:863-886): Capture::drop overwrites all len bytes using core::ptr::write_volatile(b, 0) (preventing LLVM dead-store elimination), and sep_sensor_xfer2() passes rx directly into spi_sync_transfer() under sensor->lock with 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 production crc16_ansi, Capture, Drop for Capture, and read_capture, checks fixture constants against sensor.rs, and includes a verified 3-failure negative control against the unpatched source.

Blockers

  1. §5 (CI not run on 471593d0): SEP source checks (source, rust-build, arm64 QEMU kunit, dwc3-atc-compile) is currently conclusion=action_required (awaiting maintainer workflow approval on this fork PR, run 45081870806), and Host tests has not run (check-runs: 0). Required CI must execute and pass on 471593d0 before approval.
  2. §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/aurora head (471593d0) are still outstanding (the cited M3 Air run was on an older omacom/linux-aurora#251 head 9e899a873). Once CI is approved and green, please coordinate a quick Touch ID enrol/match + regression smoke row on Touch ID hardware at 471593d0.

Non-blocking Nits

  • drivers/soc/apple/sensor.rs:815-822 (pre-existing): adding core::sync::atomic::compiler_fence(core::sync::atomic::Ordering::SeqCst) after the write_volatile loop in Capture::drop is 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 current sensor.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_volatile zeroization runs before deallocation on every post-transfer error path.
  • §4 Clean-room & attribution: Pass — both commits (5907bb1b145a, 471593d0fab7) carry human author/committer and human Signed-off-by: only, with zero AI trailers in commits.
  • §5 Evidence: Blocked — SEP source checks (action_required) and Host tests have not run on 471593d0; exact-head CI and Touch ID HW smoke/regression row outstanding.
  • §6 Naming: Pass.

@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) area:release Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 25, 2026 06:46

Superseded by the review at 471593d

@github-actions github-actions Bot removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Merge readiness at 471593d0: ready to merge

Check Detail
CI at head ok 6 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok comment at 471593d0
Conflicts ok none
PR text ok Risk: two-way · all Touch ID Macs using applesep

Areas: area:platform, area:release
Merge: gh pr merge 2888 --merge (Owners and Core through the bypass: add --admin).

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@mmdisbrow

Copy link
Copy Markdown
Contributor Author

Quick clarification on hardware for the 471593d0fab7 row: the M3 Air smoke test cited from omacom/linux-aurora#251 was run by the reviewers there, not on a machine I own. My only Touch ID Linux Mac is an M1 MacBook Air (T8103 / J313) running Arch Linux ARM.

On 471593d0fab7, all 6 SEP source checks (including capture-error-wipe, rust-build, and arm64 QEMU kunit) are green. For the rejected-read cleanup check itself, unmodified 471593d0fab7 wipes the KVec silently in Capture::drop without a runtime counter; that path is proven by tools/aurora-sep/tests/capture-error-wipe/run.py against the extracted production read_capture() and Capture::drop (9/9 pass, with the 3-failure negative control on unpatched 110861f43).

I can either build and run a Touch ID enrol/verify smoke row at exact head 471593d0fab7 on my M1 Air (T8103 / J313), or if you prefer a lab Mac row (with SELinux enforcing), could a lab Touch ID Mac claim 471593d0fab7?

@github-actions github-actions Bot added blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot) and removed needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks Tested or Risk (bot) ready-to-merge Meets the merge policy: merge it (bot) labels Nov 25, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

471593d0fab7 (batched cleanly in J616s Batch #2 5b411e230229 over main 95a983c08be4, 0 merge-tree diffs across all 6 changed files) J616s (MacBook Pro 16" M4 Pro, T6040, Apple M4 Pro (G16S B1), macOS 26.6.2 fw, guarded one-shot 7.3.0-aurora-pr2905+, default cmdline, stock Stage 2 1.0.0b17, boot_id=de17fad3) PASS: 0 failed units, Enforcing, 0 new AVC (1 matching baseline), 0 GPU faults, 0 errors in this subsystem, real rtc1 s2idle 2/2 (success=2 fail=0), eDP connected pre/post-sleep, 406600000.sep + 514600000.mtp RTKit v12 (AppleMTPFirmwareMac-5340.61.4~502, HID keyboard/trackpad/accel/actuator/touch) clean, Borealis VK dEQP-VK.api.smoke.* 8/8 (pre & post-sleep) + glsl.loops.* 624/624, Wi-Fi 3/3 ping pre/post-sleep; stock 7.3.0-aurora-fleet89 restored & verified (b67edc6c).

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Yes, please run the J313 row at 471593d0fab7: Touch ID enrol, then verify (a match and a non-match), and one rejected read if you can trigger it, plus the regression line (failed units, new kernel errors). Arch without SELinux is fine for your half.

sensor.rs is shared, so the second generation with SELinux enforcing comes from our lab Neo (J700, Fedora); it's queued with the other Touch ID rows. Ryan's J616s batch row at this head is a general no-regression run and doesn't exercise Touch ID. Once both are in, this merges.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

J700 (MacBook Neo) reduced row at 471593d0fab73739029b3c518d286ad88e4537f6: no regression found. Enrol and verify were not run on J700.

  • Not exercised: Touch ID enrol and the matching and non-matching verify. This Neo has 0 enrolled fingers, its sensor doesn't register at boot ("sensor: the power cycle failed; not registering the sensor"), and nobody may touch it. The J313 half covers those.
  • No finger-free way into the changed path. read_capture is called only from verify_one_image, no_match_tail, enrol_one_image and await_finger_lift, and all four need a registered sensor and a finger.
  • One-shot boot under Enforcing of a combined candidate with this head merged in: main 255761f plus this PR and other PRs whose files don't overlap. Against the stock 7.3.0-41 boot in the same session:
    • The SEP driver probes, and /dev/sep-bio and /dev/sep-bio-rearm are present.
    • aurora-sep.service, aurora-sep.timer, aurora-touchid-boot.service and the rearm socket are in the same states as on stock.
    • Touch ID is locked, waiting for the first password since boot, as on stock. All of this holds again after a test sleep.
    • 0 AVC, 0 failed units, and no new SEP error lines. Two "apple_sep: unknown parameter 'provision_keybag'/'xart_writes' ignored" lines come from the newer main in the candidate, not from this PR.
  • The PR's own host test (tools/aurora-sep/tests/capture-error-wipe/run.py): 9/9 at this head. The base sensor.rs fails exactly the 3 expected cases: complete and partial bus failure, and CRC rejection.

@RyanTheTide
RyanTheTide merged commit 07ee155 into aurora-silicon:main Nov 27, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform Area from CODEOWNERS (bot) area:release Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants