Skip to content

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

Closed
mmdisbrow wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
mmdisbrow:sep-capture-wipe
Closed

mmdisbrow wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
mmdisbrow:sep-capture-wipe

Conversation

@mmdisbrow

Copy link
Copy Markdown
Contributor

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.

Port of omacom/linux-aurora#251. The original remains open. Its October 29 approval records an M3 Air smoke test on the original test kernel. Kernel CI subsequently passed on original head 9e899a873, including compile and SEP host tests. Review · CI run

Changes

  • drivers/soc/apple/sensor.rs: 6+/1-, the ownership move described above.
  • 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 it in the SEP source checks under the job's pinned Rust 1.85.0.

Differences from the original PR

  • Applied to integration/aurora at 110861f with no source conflicts.
  • The suite is registered in sep-source.yml instead of tools/aurora-ci/host-tests.json, which this tree doesn't have. The original second commit, which only re-pinned that manifest to Rust 1.85.0, is therefore dropped.

Validation (local host)

  • Rust 1.85.0: all 9 cases pass.
  • Negative control against the unpatched sensor.rs from 110861f: exactly the complete-transfer-error, partial-transfer-error and CRC-rejection cases fail because image bytes are freed unwiped. The other six pass.
  • At 8ced22deb, whose tree is identical to this head (only commit trailers changed since), the arm64 SEP composite object drivers/soc/apple/apple-sep.o compiled and linked locally with SEP KUnit enabled, LLVM 23.1.5, Rust 1.85.0, and the tree's patched bindgen. The pinned base reproduced the compiler warnings. Full kernel and loadable-module builds, KUnit execution, and a hardware run of this exact head remain outstanding.

AI-assisted: OpenAI Codex for the original change, Claude Code for the port (see the Assisted-by: trailers). Commits carry my DCO sign-off.

🤖 Generated with Claude Code

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)")
Assisted-by: LLM [Codex, GPT-6] [Claude Code, claude-opus-5-5]
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.

Assisted-by: LLM [Claude Code, claude-opus-5-5]
Signed-off-by: Matt <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Review at cd1fae9.

Thanks, the fix is right. Building Capture(buf) before the SPI call means every early return after the transfer starts (partial or complete bus error, CRC mismatch) drops the owner, and its Drop zeroes all len bytes with write_volatile, so the wipe can't be optimised away. The success path hands back the same allocation, and the borrow buf = &mut capture.0 ends before Ok(capture). The host harness extracts the real read_capture()/Capture::drop from sensor.rs, and the 3-failure control against the old source shows it can fail. It's wired into sep-source.yml.

  1. Commit trailers: both commits carry Assisted-by: lines. In this repo commits carry human trailers only (your Signed-off-by is right); please move the Assisted-by note to the last line of the PR description instead. Since we don't force-push shared branches, a fresh branch with the reworded commits is the easiest way.
  2. No hardware row is needed for an ownership move like this. If you have an M3 Air at hand, one fingerprint enrol + match on this head would confirm the success path still behaves the same.

@mmdisbrow

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I've opened #2888 from a fresh branch with the reworded commits. It has the same tree as cd1fae9 and only human trailers in the commits; the assistance note is now the last line of the description.

I don't have an M3 Air. My hardware is an M1 (J313), so I can't do the enrol + match on M3. Closing this in favour of #2888.

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.

2 participants