Skip to content
This repository was archived by the owner on Feb 20, 2025. It is now read-only.
This repository was archived by the owner on Feb 20, 2025. It is now read-only.

yk_open_key causes the keyboard HID interface to reset #172

@amrbekhit

Description

@amrbekhit

When running ykinfo -s -q I noticed that the USB HID Keyboard interface is removed and re-added by the kernel. This does not happen when the equivalent ykman list command is run.

Debugging the source seems to show that the problem occurs when the device is opened:
https://github.com/Yubico/yubikey-personalization/blob/master/ykinfo.c#L206

I've faced this problem on two different systems:

  • Ubuntu 20.04.1 LTS kernel 5.4.0-62-generic.
  • An embedded system running a custom Linux distro, kernel 5.4.77

Here's the dmesg log on the Ubuntu system (it's just the keyboard interface being re-recognised):

[89123.923064] input: Yubico YubiKey OTP+FIDO+CCID as /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141
[89123.982263] hid-generic 0003:1050:0407.0076: input,hidraw3: USB HID v1.10 Keyboard [Yubico YubiKey OTP+FIDO+CCID] on usb-0000:00:1d.7-2.2.4.4/input0

Likewise the udevadm log:

$ udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[89144.483982] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/event16 (input)
KERNEL[89144.511726] change   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::numlock (leds)
KERNEL[89144.511768] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::numlock (leds)
KERNEL[89144.511802] change   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::capslock (leds)
KERNEL[89144.511829] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::capslock (leds)
KERNEL[89144.511866] change   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::scrolllock (leds)
KERNEL[89144.511893] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::scrolllock (leds)
KERNEL[89144.511918] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::compose (leds)
KERNEL[89144.511944] change   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::kana (leds)
KERNEL[89144.511969] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::kana (leds)
KERNEL[89144.539972] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141 (input)
KERNEL[89144.540032] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/hidraw/hidraw3 (hidraw)
KERNEL[89144.540072] unbind   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076 (hid)
KERNEL[89144.540122] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076 (hid)
KERNEL[89144.540164] unbind   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0 (usb)
UDEV  [89144.542762] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/event16 (input)
UDEV  [89144.542847] change   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::scrolllock (leds)
UDEV  [89144.542910] change   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::numlock (leds)
UDEV  [89144.542972] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::compose (leds)
UDEV  [89144.543034] change   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::kana (leds)
UDEV  [89144.543095] change   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::capslock (leds)
UDEV  [89144.546854] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/hidraw/hidraw3 (hidraw)
UDEV  [89144.547444] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::numlock (leds)
UDEV  [89144.548891] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::kana (leds)
UDEV  [89144.549632] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::scrolllock (leds)
KERNEL[89144.551756] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077 (hid)
KERNEL[89144.552038] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142 (input)
KERNEL[89144.611725] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/event16 (input)
KERNEL[89144.611766] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::numlock (leds)
KERNEL[89144.611798] change   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::numlock (leds)
KERNEL[89144.611823] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::capslock (leds)
KERNEL[89144.611853] change   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::capslock (leds)
KERNEL[89144.611878] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::scrolllock (leds)
KERNEL[89144.611908] change   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::scrolllock (leds)
KERNEL[89144.611934] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::compose (leds)
KERNEL[89144.611959] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::kana (leds)
KERNEL[89144.611988] change   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::kana (leds)
KERNEL[89144.612293] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/hidraw/hidraw3 (hidraw)
KERNEL[89144.612344] bind     /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077 (hid)
KERNEL[89144.612384] bind     /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0 (usb)
UDEV  [89144.612672] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141/input141::capslock (leds)
UDEV  [89144.616398] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076/input/input141 (input)
UDEV  [89144.618745] unbind   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076 (hid)
UDEV  [89144.622283] remove   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0076 (hid)
UDEV  [89144.626525] unbind   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0 (usb)
UDEV  [89144.632102] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077 (hid)
UDEV  [89144.637788] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142 (input)
UDEV  [89144.644479] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/hidraw/hidraw3 (hidraw)
UDEV  [89144.644582] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::scrolllock (leds)
UDEV  [89144.644637] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::numlock (leds)
UDEV  [89144.644684] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::compose (leds)
UDEV  [89144.644731] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::capslock (leds)
UDEV  [89144.644778] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::kana (leds)
UDEV  [89144.648808] change   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::scrolllock (leds)
UDEV  [89144.648979] change   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::kana (leds)
UDEV  [89144.649335] change   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::numlock (leds)
UDEV  [89144.652645] change   /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/input142::capslock (leds)
UDEV  [89144.746689] add      /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077/input/input142/event16 (input)
UDEV  [89144.749993] bind     /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0/0003:1050:0407.0077 (hid)
UDEV  [89144.755345] bind     /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2.4/2-2.2.4.4/2-2.2.4.4:1.0 (usb)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions