New fix for the fingerprint reader HP Elite Dragonfly Chromebook

System Details

  • Device: HP Elite Dragonfly Chromebook
  • OS: manjaro linux
  • Firmware Type: UEFI Full ROM
  • Firmware Version: MrChromebox-2512.2 (01/25/2026)
  • Internal storage type: [SATA, NVMe, eMMC, UFS] (if applicable)

Summary of the Issue

The ChromeOS fingerprint driver for libfprint (AUR package libfprint-crfpmoc-git, commit 5644259) didn’t work on my HP Elite Dragonfly Chromebook (Redrix): enrolling a finger always failed. With help from an AI assistant, I tracked it down to three bugs in the driver and made a patch that fixes them. My fingerprint now enrolls and unlocks the KDE lock screen. I’m new to this and am sharing it in case it helps others or the driver developers. The patch and details are at the end.

Steps to Reproduce

  1. On a Chromebook with a ChromeOS fingerprint sensor (/dev/cros_fp), install fprintd and libfprint-crfpmoc-git from the AUR (mine: Redrix, Manjaro KDE).
  2. Let fprintd open the sensor with a systemd drop-in for fprintd.service containing DeviceAllow=/dev/cros_fp rw, then restart fprintd.
  3. Run fprintd-enroll.

Expected Behavior

fprintd-enroll asks for several finger presses and saves the fingerprint, which can then unlock the lock screen, sudo, and so on.

Actual Behavior

fprintd-enroll fails right away with enroll-unknown-error. The fprintd log shows Device reported an error during identify for enroll: ioctl failed: Message too long, and the kernel log shows cros-ec-spi spi-PRP0001:00: packet too long (4 bytes, expected 0). With that worked around, fprintd crashes (SIGSEGV) on the first sensor event, right after fpi_device_get_cancellable: assertion 'FP_IS_DEVICE (device)' failed.

System Information

[paste the output of the printf command here]
fprintd 1.94.5, libfprint-crfpmoc-git 1.94.8.r337.g5644259
FPMCU: RO bloonchipper_v2.0.5938-197506c1, RW bloonchipper-v2.0.29318-6543bef

Cause and Fix

  1. “Message too long”: Four EC_CMD_FP_MODE calls are sent with insize 0 (clear-storage, the reset-sensor step, enroll reset, verify reset), but FP_MODE always returns struct ec_response_fp_mode, so the kernel rejects the reply. Fix: pass sizeof (struct crfpmoc_ec_response_fp_mode).

  2. Segfault: crfpmoc_read_bytes is set on a g_pollable_input_stream_create_source() source as a plain GSourceFunc, but GLib calls pollable-source callbacks as GPollableSourceFunc (GObject *stream, gpointer user_data), so the stream gets used as the FpiSsm, and a NULL error is then dereferenced. Fix: correct signature and cast, guard the NULL error, and unref the source after attaching.

  3. Enrolled prints can’t work in a later session: crfpmoc_init_keys() picks a random seed and user context on every open, and the FPMCU derives the template encryption key from both, so a print enrolled in one fprintd session can’t be uploaded (decrypted) in the next. My patch uses the fixed default values instead. Persisting a random value would probably be the better fix, so this one is a design call for the maintainers.

Cosmetic issue: enrollment reports enroll-retry-scan for every accepted image, because crfpmoc_enroll_check_cb reports progress as a retry and never increments stage.

Applying it to the AUR package (the patch is against 5644259; newer commits may not need it or may not apply). Save the patch below as ~/crfpmoc-fix.patch, then:

cd ~/libfprint-crfpmoc-git          # your clone of the AUR package
makepkg -Co                         # fresh source checkout, no build
git -C src/libfprint apply ~/crfpmoc-fix.patch
makepkg -efi --nocheck              # build the patched source and install

--nocheck is needed because the recorded umockdev tests expect the old FP_MODE calls. Reboot before enrolling, so the sensor isn’t holding a random seed set by the unpatched driver.

--- a/libfprint/drivers/crfpmoc/crfpmoc.c
+++ b/libfprint/drivers/crfpmoc/crfpmoc.c
@@ -403,7 +403,7 @@
  * to see if a timeout is active.
  */
 static gboolean
-crfpmoc_read_bytes (gpointer user_data)
+crfpmoc_read_bytes (GObject *pollable_stream, gpointer user_data)
 {
   g_autoptr(GError) error = NULL;
   FpiSsm *ssm = user_data;
@@ -451,7 +451,7 @@
       fpi_ssm_mark_failed (ssm,
                            fpi_device_error_new_msg (FP_DEVICE_ERROR_GENERAL,
                                                      "Error polling for MKBP event: %s",
-                                                     error->message));
+                                                     error ? error->message : "unknown error"));
       return G_SOURCE_REMOVE;
     }
 
@@ -593,8 +593,12 @@
   GSource *poll_source = g_pollable_input_stream_create_source (
     G_POLLABLE_INPUT_STREAM (data->poll_input_stream),
     fpi_device_get_cancellable (device));
-  g_source_set_callback (poll_source, crfpmoc_read_bytes, ssm, NULL);
+  /* GPollableSourceFunc: GLib passes the stream as the first argument */
+  g_source_set_callback (poll_source,
+                         (GSourceFunc) (void (*) (void)) crfpmoc_read_bytes,
+                         ssm, NULL);
   data->poll_source = g_source_attach (poll_source, NULL);
+  g_source_unref (poll_source);
 }
 
 /* Enable device event reporting and queue a callback when there is
@@ -723,7 +727,8 @@
       data->clear_step = 1;
       p.mode = CRFPMOC_FP_MODE_RESET_SENSOR;
       new_transfer = crfpmoc_ec_transfer_new_cmd (device, CRFPMOC_EC_CMD_FP_MODE, 0,
-                                                  &p, sizeof (p), 0);
+                                                  &p, sizeof (p),
+                                                  sizeof (struct crfpmoc_ec_response_fp_mode));
       crfpmoc_ec_transfer_submit_cmd (new_transfer, fpi_device_get_cancellable (device),
                                       crfpmoc_clear_storage_cb, ssm);
     }
@@ -1025,9 +1030,13 @@
   fpi_device_open_complete (device, error);
 }
 
-/* Initialise the per-session encryption seed and user context. In emulation
- * mode fixed test values are used so the recorded ioctl replay stays
- * deterministic; on real hardware random values are generated.
+/* Initialise the encryption seed and user context.
+ *
+ * The FPMCU derives the template encryption key from both values, so they
+ * must be the same in every session and after every reboot. Random values
+ * per open would make previously enrolled prints impossible to upload
+ * (decrypt) in any later session. Templates still can only be decrypted
+ * inside the FPMCU, which holds its own internal secret.
  */
 static void
 crfpmoc_init_keys (FpiDeviceCrfpMoc *self)
@@ -1037,19 +1046,8 @@
   G_STATIC_ASSERT (sizeof (CRFPMOC_DEFAULT_SEED) - 1 == CRFPMOC_FP_CONTEXT_TPM_BYTES);
   G_STATIC_ASSERT (sizeof (CRFPMOC_DEFAULT_CONTEXT) - 1 == CRFPMOC_FP_CONTEXT_USERID_BYTES);
 
-  if (fpi_device_emulation_mode_enabled (FP_DEVICE (self)))
-    {
-      memcpy (self->seed, CRFPMOC_DEFAULT_SEED, sizeof (self->seed));
-      memcpy (self->context, CRFPMOC_DEFAULT_CONTEXT, sizeof (self->context));
-    }
-  else
-    {
-      for (size_t i = 0; i < sizeof (self->seed); i++)
-        self->seed[i] = (guint8) g_random_int_range (0, 256);
-
-      for (size_t i = 0; i < sizeof (self->context); i++)
-        self->context[i] = (guint8) g_random_int_range (0, 256);
-    }
+  memcpy (self->seed, CRFPMOC_DEFAULT_SEED, sizeof (self->seed));
+  memcpy (self->context, CRFPMOC_DEFAULT_CONTEXT, sizeof (self->context));
 }
 
 static void
@@ -1339,7 +1337,8 @@
   CrfpMocEcTransfer *transfer;
 
   transfer = crfpmoc_ec_transfer_new_cmd (device, CRFPMOC_EC_CMD_FP_MODE, 0,
-                                          &p, sizeof (p), 0);
+                                          &p, sizeof (p),
+                                          sizeof (struct crfpmoc_ec_response_fp_mode));
   crfpmoc_ec_transfer_submit_cmd (transfer, NULL, crfpmoc_ssm_ec_transfer_cb, ssm);
 }
 
@@ -1611,7 +1610,8 @@
   CrfpMocEcTransfer *transfer;
 
   transfer = crfpmoc_ec_transfer_new_cmd (device, CRFPMOC_EC_CMD_FP_MODE, 0,
-                                          &p, sizeof (p), 0);
+                                          &p, sizeof (p),
+                                          sizeof (struct crfpmoc_ec_response_fp_mode));
   crfpmoc_ec_transfer_submit_cmd (transfer, NULL, crfpmoc_ssm_ec_transfer_cb, ssm);
 }
 
@@ -1841,7 +1841,8 @@
       data->clear_step = 0;
 
       transfer = crfpmoc_ec_transfer_new_cmd (device, CRFPMOC_EC_CMD_FP_MODE, 0,
-                                              &p, sizeof (p), 0);
+                                              &p, sizeof (p),
+                                              sizeof (struct crfpmoc_ec_response_fp_mode));
       crfpmoc_ec_transfer_submit_cmd (transfer, fpi_device_get_cancellable (device),
                                       crfpmoc_clear_storage_cb, ssm);
       break;