noctalia-shell icon indicating copy to clipboard operation
noctalia-shell copied to clipboard

[BUG] FingerprintAuthenticator::stop() skips Release after verify-disconnected, leaving fprintd claimed by Noctalia

Open alnrog opened this issue 2 months ago • 0 comments

Submission checklist

  • [x] I have searched existing issues and confirmed this is not a duplicate.
  • [x] I am using the latest available version of Noctalia.

Bug description

When fingerprint verification on the lock screen ends with verify-disconnected, FingerprintAuthenticator sends VerifyStop but never sends Release. The fprintd claim stays with Noctalia's session-long system-bus connection. The next Claim from Noctalia is then rejected with net.reactivated.Fprint.Error.AlreadyInUse, and fingerprint authentication is unavailable until a later cleanup happens to release the claim.

In normal use this is easy to hit because of a separate property of the lock screen. Verification starts as soon as the session locks and has no time limit. On an unattended lock, libfprint's time-based thermal protection eventually cancels the verification with FP_DEVICE_ERROR_TOO_HOT, and fprintd reports that to clients as verify-disconnected.

I think these are two separate things:

  • the bug: a claim that Noctalia owns is abandoned after verify-disconnected;
  • the exposing behaviour: unbounded verification that starts at lock.

The claim leak is a bug regardless of how the lock-screen UX should behave.

Steps to reproduce

Preconditions: no other process is using the fingerprint reader, and fprintd is not restarted during the test.

  1. Lock the session (e.g. noctalia msg session lock).
  2. Don't touch the sensor or the keyboard for at least 4 minutes. The lock screen switches to "Fingerprint reader disconnected".
  3. Unlock with the correct password on the first attempt.
    • A failed password attempt calls startFingerprint() again. That new Claim fails, but it leaves a device proxy with m_abort cleared, so the next stop() does send Release. That masks the bug; see "Source-level cause".
  4. Lock again. Fingerprint is unavailable straight away. The Noctalia log shows could not claim fingerprint device: net.reactivated.Fprint.Error.AlreadyInUse] Device was already claimed.
  5. Unlock with the password. Now released fingerprint device is logged, and the next lock claims the reader normally.

Under these conditions I reproduced the AlreadyInUse failure consistently: in six leak cycles that were followed by a password-only unlock and another lock, with no counterexample.

Expected behavior

  • When verification ends for any reason, Noctalia releases the claim it holds.
  • A recoverable fingerprint error does not leave Noctalia blocking its own next Claim.
  • Leaving the lock screen unattended does not break fingerprint authentication for the next attempt.

Actual behavior

  • Verification runs for the whole lock until libfprint's protective HOT state cancels it.
  • fprintd logs Device reported an error during verify: Device disabled to prevent overheating. and emits VerifyStatus("verify-disconnected", done=true).
  • Noctalia calls VerifyStop but not Release.
  • fprintd keeps the session for Noctalia's connection, so the next Claim from that same connection is rejected with AlreadyInUse.

Logs / error output

<details>
<summary>Selected logs (one leak cycle, then the next lock)</summary>

Noctalia log (debug level), local time:


09:29:33.362 [INF] [lockscreen] session lock requested
09:29:33.564 [INF] [fingerprint] claimed fingerprint device
09:29:33.598 [DBG] [fingerprint] fingerprint verification started
09:33:30.070 [DBG] [fingerprint] verify status: verify-disconnected (done=true)
09:33:30.073 [DBG] [fingerprint] fingerprint verification stopped
11:20:02.009 [INF] [lockscreen] session unlock requested        <- password unlock; no "released"
11:26:00.574 [INF] [lockscreen] session lock requested
11:26:00.660 [INF] [fingerprint] could not claim fingerprint device: [net.reactivated.Fprint.Error.AlreadyInUse] Device was already claimed
11:27:31.274 [INF] [fingerprint] released fingerprint device    <- password submitted; stale claim released
11:27:31.369 [INF] [lockscreen] session unlock requested


fprintd (journal, same clock, same fprintd process throughout):


09:33:30.070195 fprintd: Device reported an error during verify: Device disabled to prevent overheating.
11:26:00.649584 fprintd: Authorization denied to :1.33 to call method 'Claim' for device 'ELAN Fingerprint Sensor': Device was already claimed


`:1.33` is Noctalia's system-bus connection (`busctl --system list`). Between 09:33:30 and 11:26:00 there was no Noctalia or fprintd restart and no failed password.

</details>

Noctalia version

v5.1.0

Compositor

Niri

Distribution

Arch-based

Environment information

- Arch Linux: Noctalia 5.1.0 (distribution package), niri 26.04 (Wayland).
- fprintd 1.94.5, libfprint-tod 1.95.2+tod1.
- ELAN fingerprint reader `04f3:0c4b` ("press" type).
- The HOT state below comes from libfprint's generic, time-based thermal model, not from a physical   temperature reading from this sensor.
- `src/auth/fingerprint_authenticator.{h,cpp}` is identical in `v5.1.0` and on `main` at `0433e3f8517f` (checked 2026-09-26). The source references below point at that commit.

Additional context

Evidence

  • The same sequence appeared in 8 unattended lock cycles, both keybind- and swayidle-triggered.
  • Once, I predicted the cutoff time (~236 s after verification started) before it happened, and it matched to within a second.
  • Before the next natural lock, I also predicted that its Claim would fail with AlreadyInUse. It did.
  • The rejected Claim was addressed to :1.33, which is the Noctalia process's system-bus connection. A later Release from :1.33 succeeded. fprintd only accepts Release from the connection that owns the session (_fprint_device_check_claimed), so the stuck claim was Noctalia's own.
  • Normal cases work: with a finger presented promptly, the log shows claimed → verification started → verify-match → released → unlock.

Source-level cause

In src/auth/fingerprint_authenticator.cpp:

  • In handleVerifyStatus(), the MatchResult::Disconnected branch calls stopVerify() (which sends VerifyStop) and then sets m_abort = true.

  • stop() then does:

    if (!m_abort) {
      releaseDevice();   // sends Release
    } else {
      m_device.reset();  // proxy dropped, Release skipped
    }
    

    stop() is reached from LockScreen::unlock(), LockScreen::tryAuthenticate() (before password PAM) and LockScreen::handleFinished(). After a disconnect, none of them releases the claim.

  • start() clears m_abort, and a new proxy sends Claim from the same connection. fprintd rejects Claim whenever any session exists, including one owned by the caller.

  • That failed attempt leaves a proxy with m_abort == false, so the next stop() sends Release. This is why the problem clears itself one attempt later.

fprintd 1.94.5 maps FP_DEVICE_ERROR_TOO_HOT, along with PROTO and REMOVED, to verify-disconnected (verify_result_to_name()). So Noctalia cannot tell a temporary HOT state from a removed device, which is one more reason to release in both cases.

A short-lived client such as pam_fprintd doesn't hit this: its connection closes when the transaction ends, and fprintd then drops the claim in its client-vanished handler. Noctalia keeps one SystemBusconnection for the whole session, so it has to callRelease` explicitly.

The exposing behaviour is in src/shell/lockscreen/lock_screen.cpp:

  • LockScreen::handleLocked() calls startFingerprint() as soon as the lock is confirmed.
  • LockScreen::handleAuthResult() calls it again after a failed password.
  • FingerprintAuthenticator::startVerify() has no deadline. m_retryTimer is only used for the 250 ms re-arm after no-match or unknown errors.

Why about 3–4 minutes

libfprint keeps a protective, time-based thermal estimate for each device, driven by how long the device has been active or idle. With the default constants, continuous verification reaches the protective HOT state after about 180 s on a freshly started fprintd and about 236 s once the device has fully cooled. libfprint then cancels the operation with FP_DEVICE_ERROR_TOO_HOT ("Device disabled to prevent overheating").

The cutoffs I observed match these values closely. This is libfprint's protection working as designed; it doesn't show that the sensor physically overheated.

Thermal model details

libfprint/fp-device-private.h defines DEFAULT_TEMP_HOT_SECONDS = 180 and DEFAULT_TEMP_COLD_SECONDS = 540. HOT is reached at ratio 1 − 1/(e+1) ≈ 0.731; a new device starts at 1/(e+1) ≈ 0.269.

fpi_device_update_temp() (libfprint/fpi-device.c) moves the ratio toward 1 while the device is active (1−(1−r)e^(−t/180)) and decays it while idle (r·e^(−t/540)). When the ratio reaches HOT, it cancels the running verify/identify/enroll with FP_DEVICE_ERROR_TOO_HOT, and new operations are refused until the device cools.

Cutoffs between 180 s and 236 s (I also saw 202 s and 219 s) are explained by earlier activity on the same fprintd instance.

Regression / v4 comparison

This did not show up with Noctalia v4 on the same machine and the same fprintd/libfprint versions. There were no HOT events in several hundred v4-era fprintd activations.

With autoStartAuth: false, v4's LockContext started the PAM transaction, and with it pam_fprintd, only from tryUnlock() when Enter was pressed. pam_fprintd then bounded that attempt with its default 30 s timeout. In 81 v4 locks longer than five minutes, fprintd was never activated at lock time.

I'm not suggesting a return to pam_fprintd. The comparison just explains why the leak was never triggered before.

Relation to #4473

I first thought this was related to #4473 because of the shared AlreadyInUse symptom. The traces seem to show a different failure path, though:

  • #4473 is on a Synaptics reader, is triggered by lock-and-suspend/resume, and shows fprintd suspend-time "device is still busy" errors.
  • This report reproduces without suspend. It shows the TOO_HOT → verify-disconnected → skipped Release sequence, and the rejected claim belongs to Noctalia's own connection.

The two might share a general weakness, such as no recovery from a stale self-owned claim, but they look like different bugs to me.

Relation to #3602

GitHub also suggests #3602 as a possible duplicate, but the failure occurs at a different stage. In #3602, Claim() is rejected with PermissionDenied, so fingerprint verification never reaches VerifyStart(). In this report, both Claim() and VerifyStart() succeed; the failure happens later, after verify-disconnected, when the owned claim is not released and the subsequent Claim() fails with AlreadyInUse.

The symptoms are related to fingerprint authentication, but the observed failure paths appear to be different.

Proposed correctness fix

Essential: a claim that Noctalia obtained must not be abandoned just because verification ended with verify-disconnected. Concretely:

  1. Track explicitly whether Noctalia currently owns a claim: set it when Claim succeeds, clear it when Release succeeds.
  2. On every cleanup path where Noctalia still owns a claim, send VerifyStop (if verifying) and then Release. That includes after verify-disconnected and after the no-match/unknown-error retries run out. If fprintd or the device is really gone, Release fails quickly, and that error is already caught.

Hardening (optional):

  1. Give the synchronous VerifyStop/Release calls a short explicit timeout using .withTimeout(...), as Noctalia already does elsewhere (e.g. desktop_entry_launch.cpp). Without it, a busy fprintd can block the lock screen for sd-bus's 25 s default per call.
  2. Add a guarded one-shot repair: if Claim returns AlreadyInUse and local state says a previous Release did not complete, send Release once and retry Claim once, with no loop.
    • If Noctalia has no record of owning a claim, it should report the reader as busy and not call Release at all.
    • This cannot take the reader from another program: fprintd rejects Release from any connection other than the session owner, and inside Noctalia only the lock screen's authenticator talks to fprintd.

Lock-screen behaviour (separate discussion)

This also exposed a separate lock-screen UX question. v5 starts fingerprint verification as soon as the session locks and leaves it running indefinitely, whereas my v4 setup used a bounded, user-triggered attempt. I have a native-v5 design for bounded, explicitly activated verification (e.g. a ~30 s attempt started from the lock screen, with no automatic re-arm), but I'd rather discuss that separately. The fix above stands on its own.

Tests

I'd suggest regression tests with a fake fprintd service, following the existing upower_charge_limit_integration / dbus-run-session pattern:

  1. verify-disconnected leads to VerifyStop and Release.
  2. Normal and deadline cleanup send Release exactly once.
  3. AlreadyInUse caused by another client: no Release, busy status.
  4. A failed or timed-out own Release leads to at most one guarded recovery attempt, with no loop and no long UI block.

Next step

If this direction looks right, I'd be happy to prepare the correctness fix as a focused PR with those tests. I can also collect more logs or run diagnostics on this hardware if that helps.


alnrog avatar Sep 26 '26 10:09 alnrog