Skip to content

Keep fingerprint detection from hanging on a wedged reader - #15334

Open
themodev wants to merge 2 commits into
omacom:quattrofrom
themodev:fingerprint-detect-timeout
Open

themodev wants to merge 2 commits into
omacom:quattrofrom
themodev:fingerprint-detect-timeout

Conversation

@themodev

Copy link
Copy Markdown

omarchy-update stalled forever in the post-update hook on my Framework 13. The Goodix reader (27c6:609c) had wedged after a suspend: fprintd was stuck in the kernel mid-ioctl and held the USB device lock. Reading the device's product string in sysfs needs that lock, so omarchy-hw-fingerprint blocked forever, and with it setup-fingerprint.hook and the whole update. The shell's own call to the detector had been stuck for days too.

Now the product read gives up after a second (timeout --kill-after=1s 1s cat, same idiom as omarchy-hw-hybrid-gpu), and the existing vendor-ID check decides. A wedged Goodix reader is still detected, because fprintd's claim goes through usbfs, which the driver check already treats as userspace.

Verified

  • test/shell.d/hw-fingerprint-test.sh: two new cases use a FIFO as the product file to model a read that never returns. Without the fix the test hangs; with it, everything passes in about 2s. The fingerprint-package and fingerprint-invitation tests still pass.
  • On the affected machine, while the reader was still wedged, the patched script returned "reader present" in 1.0s. The packaged one hung.

The underlying fprintd/kernel wedge needs a reboot to clear. This change only stops it from taking the update down with it.

Made by Claude Opus 5.5 via Claude Code

Reading a USB device's product string takes the device lock. When fprintd
gets stuck mid-ioctl on a reader that never woke from suspend, that lock is
held forever, so omarchy-hw-fingerprint blocked every caller, including the
post-update hook, which stalled omarchy-update indefinitely. Cap the read at
a second and let the vendor check decide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 17, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 1bac03e, nothing found that needs changing.

What ran, on a disposable Omarchy worker: a separate reproduction, independent of the PR's own tests, that points OMARCHY_USB_DEVICES_PATH at a fake device whose product file is a FIFO with no writer. With the quattro copy of omarchy-hw-fingerprint, both a Goodix (27c6) and an unrelated vendor hang until the 10s harness deadline kills them. With this head, the Goodix device is detected in about a second and the unrelated one is rejected. Putting back the old $(<"$dev/product") line brings the hang back. ./test/cli passed, and so did hw-fingerprint-test.sh (13), fingerprint-package-test.sh (7) and fingerprint-invitation-test.sh (1), run with the compositor session wired in.

What was only read: the kernel side. In drivers/usb/core/sysfs.c the product attribute takes usb_lock_device_interruptible(), so the SIGTERM from timeout does interrupt a cat waiting on a held device lock. idVendor and the driver symlinks in has_kernel_driver don't take that lock. The wedged reader itself couldn't be reproduced on a VM. The FIFO only models a read that never returns.

Second opinion: Codex Medium reviewed the same diff. It agreed there are no defects, but its independence from this review isn't guaranteed. It traced the locking in the kernel source on its own and reached the same answer. It also pointed out one related path outside this PR: bin/omarchy-hw-elgato-camlink-4k greps every USB product attribute with no bound, and migrations/1788862626.sh calls it during omarchy-update. While that migration is still pending, a wedged device could still stall an update there. That predates this change and isn't a reason to hold it.

The change is one line plus two tests, which is the right size for the problem. Nothing is left for the author. It now waits on the maintainer.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Oct 19, 2026
Both sides appended cases to hw-fingerprint-test.sh. The platform-reader cases from omacom#14675 run first and remove their fingerprint-readers file, so the wedged-reader cases still exercise the USB scan alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 21, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This stopped merging cleanly after #14675 (platform-named fingerprint readers) landed on quattro, so I merged quattro into the branch as 5611e77. The only conflict was in test/shell.d/hw-fingerprint-test.sh, where both sides had appended cases at the end. The resolution keeps both: #14675's platform-reader cases run first and remove their fingerprint-readers file, then your wedged-reader cases run against the USB scan alone. Against quattro, the diff is still exactly your one-line change and two tests.

What ran, on a disposable Omarchy worker, at 5611e77: the same FIFO reproduction as before, with a fake device whose product file has no writer. The quattro copy of omarchy-hw-fingerprint hangs until the 10s deadline for both a Goodix (27c6) device and an unrelated vendor. The head detects the Goodix device and rejects the other one. Putting back the unbounded read brings the hang back, and with it hw-fingerprint-test.sh hangs too. ./test/cli passed, and so did hw-fingerprint-test.sh (25), fingerprint-package-test.sh (18) and fingerprint-invitation-test.sh (1), run with the compositor session wired in.

Second opinion: Codex Medium reviewed the merge and found no defects. Its independence from this review isn't guaranteed. It checked that nothing from either side was lost, and that the FIFO cases still exercise the vendor fallback now that the test runs a copy of the command with a fixture platform root. It also noted that #14675's platform block reads each named file with an unbounded $(<"$reader_file") before the USB scan. That predates this PR, and nothing suggests Touch ID's attribute blocks the way a wedged USB device does, so it isn't a reason to hold this.

Nothing is left for you. This now waits on the maintainer.

@greptile-apps

greptile-apps Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change reaches fingerprint detection and the paths that call it.

The PR appears safe to merge, with a non-blocking improvement needed to keep its regression tests from hanging.

Findings

  1. P2 Regression tests can hang ▶

Summary

Bounds USB product-name reads so a stuck reader can fall back to vendor detection.

  • Fingerprint detection moves on when a product read stalls.

Reviews (1) · Last reviewed commit: "Merge quattro into fingerprint-detect-ti..." · Reviewed by Greptile

Comment on lines +173 to +179
write_usb_devices '27c6:609c'
hang_product 1-0
assert_detects "a reader whose product read hangs is detected by vendor"

write_usb_devices '1234:5678'
hang_product 1-0
assert_rejects "a non-reader whose product read hangs is rejected"

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.

P2 Regression tests can hang

The new FIFO tests rely on the detector’s own timeout to finish. If that timeout is removed or broken, both the test and test/shell wait forever instead of reporting a failure. Give these calls an independent deadline and explicitly fail when it expires; assert_rejects must not count an expired deadline as a successful rejection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants