Skip to content

soc: apple: sep: wait for the verify worker in PREPARE_ENROL - #4060

Open
e-fu wants to merge 1 commit into
aurora-silicon:mainfrom
e-fu:sep-prepare-enrol-wait
Open

e-fu wants to merge 1 commit into
aurora-silicon:mainfrom
e-fu:sep-prepare-enrol-wait

Conversation

@e-fu

@e-fu e-fu commented Dec 3, 2026 •

Copy link
Copy Markdown

What: SEP_BIO_PREPARE_ENROL waits for the verify worker before its idle check, as ENROL_START and VERIFY_START already do. Without the wait, enrolling a second finger can fail with EBUSY when fprintd starts the enrolment right after its duplicate check.
Tested: J614s (14-inch MacBook Pro, M4 Pro, T6040) passed with the code change from 72df143 on downstream 7.3.0-5-1.3-ARCH with #2800, #3619 and #2371. The second finger enrolled on the first try, and sudo authenticated with either finger. A third finger then enrolled as well; after deleting it with fprintd-delete -f, sudo still matched the other two and refused the deleted one. Upstream main was not booted.
Risk: two-way door · Macs with Touch ID under the SEP biometric driver; tested on T6040 only
Not yet: An enrolment check after booting upstream main with 72df143cd3ae. Also untested on J614s is enrolment after suspend.

Details

When fprintd checks for a duplicate before an enrolment, it identifies the finger against the enrolled prints first. On a no-match the driver reports the result first, and the verify worker then saves the lockout record and collects the background result. fprintd starts the enrolment as soon as it has the result, and bio_prepare_enrol() returns EBUSY because the session is not idle yet.

bio_prepare_enrol() now waits for the worker with wait_for_worker_exit(&mut session, false) before the idle check. A session that is still busy after the wait still gets EBUSY.

The first finger is not affected: with an empty gallery libfprint answers the duplicate check itself, without arming the sensor.

Evidence

fprintd 1.94.5, one finger already enrolled. Without the patch fprintd-enroll (and the Omarchy fingerprint setup that calls it) fails right after the first touch; fprintd logs Device reported an error during enroll: ioctl failed: Device or resource busy. The journal only names a generic ioctl error; the call order in libfprint and the idle check in the driver point to SEP_BIO_PREPARE_ENROL. The post-result work finished 295 ms and 331 ms after the touch in the two failures.

Kernel Second finger
7.3.0-5 + carries two EBUSY failures captured in the journal, each after the first touch
7.3.0-5 + carries + this change enrolled on the first try; sudo matches with either finger

Kernel log with the patch:

verify: no enrolled finger matched the capture (enclave answered user -1, Linux enrolments use user 1000)
verify: no match; the match operation stays open for the next touch of this authentication
verify: match operation ended (MATCH_CANCEL) at an enrolment
enrol: enrolment operation opened (OPERATION_DEVICE_LIST, 1 device(s))
...
sbio: user 1000 now has 2 enrolled identities in the enclave

After that, fprintd-list shows both fingers.

Enrolling a second finger can fail with EBUSY if the enrolment is
prepared before the verify worker exits.

When fprintd checks for a duplicate before an enrolment, it identifies
the finger against the enrolled prints first. On a no-match the driver
reports the result first and the verify worker then saves the lockout
record and collects the background result, which takes a few hundred
milliseconds. fprintd starts the enrolment as soon as it has the result,
and SEP_BIO_PREPARE_ENROL refuses it with EBUSY because the session is
not idle yet. ENROL_START and VERIFY_START already wait for the worker
with wait_for_worker_exit(); PREPARE_ENROL does not.

The first finger is not affected: with an empty gallery libfprint
answers the duplicate check itself, without arming the sensor.

Wait for the worker in PREPARE_ENROL as well, and keep the EBUSY for a
session that is still busy afterwards.

Tested on a MacBook Pro 14" M4 Pro (J614s) with the patch on top of the
7.3.0-5 release (same code at this spot): the second finger enrols on
the first attempt; before, two attempts in a row ended with EBUSY.

Signed-off-by: E.FU <719935+e-fu@users.noreply.github.com>
@e-fu
e-fu requested review from a team as code owners December 3, 2026 04:59
@e-fu
e-fu requested review from Acelogic and scottjones and a balanced review from Copilot December 3, 2026 04:59
@github-actions github-actions Bot added area:platform Area from CODEOWNERS (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 Dec 3, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T05:08:32.865454Z 72df143 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Merge readiness at 72df143c: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok in the PR body at 72df143c
Conflicts ok none
PR text ok Risk: two-way · Macs with Touch ID under the SEP biometric driver; tested on T6040 only

Areas: area:platform

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No actionable issues were found in the reviewed changes.

No open issues 🎉

What changed in this PR

This PR addresses second-finger enrolment failures by making the Apple SEP biometric driver wait for the verify worker before preparing enrolment.

Changes:

  • Waits for worker completion in bio_prepare_enrol(), matching the existing enrolment-start behavior.
  • Preserves the EBUSY response if the session remains busy afterward.
File Description
drivers/​soc/​apple/​sbio.rs Adds the worker-exit wait before the enrolment preparation idle check.

Review effort: Balanced

@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.

Read against main 13dc5a79c0ec. This is the same wait ENROL_START already does, and it sits in the right place:

  • waiting_on_worker(session, false) is only true while the opener's own finished verify still has its worker running, so a second opener or a live capture still gets EBUSY.
  • The condition variable drops the session lock while it waits, so the worker can finish. A signal or shutdown ends the wait as in ENROL_START, and a timeout falls through to the old EBUSY.
  • After the wait, the idle check runs under the same lock hold.

Approved at 72df143cd3ae. Your J614s result covers the fix. The missing part is a boot of main plus this commit: if you get there first, a line with the head SHA is enough. Otherwise we add it to our next T8140 or T6050 trial kernel (start an enrolment while idle, then cancel it).

@github-actions github-actions Bot added blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ci-failing A check failed at the PR head (bot) and removed 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 Dec 3, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

On 72df143cd3ae merged with main c09b61228e62 (tree 8934fd77c4e4), python3 -I tools/asahi/run-host-tests.py --jobs 2 --only <group> passed sep-suspend-errors (22/22) and sep-factory-records (19/19) in the Ubuntu 24.04 CI container. python3 -I -B tools/aurora-sep/tests/test_sbio_exchange.py hit the same fixture compile error on base and merge tree: the test's CondVar stub lacks wait_timeout. The arm64 SEP KUnit compile did not get the build slot in this pass. The corrected PR-text run passed.

The author's J614s result exercises the patch in a downstream kernel. The pending hardware result is Touch ID enrolment after booting upstream main with this head, as requested in the approval.

This branch has not been deployed

No deployments
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) blast:m4 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants