Skip to content

Commit

Permalink
usb: kbd: Ignore Yubikeys
Browse files Browse the repository at this point in the history
We currently only support one USB keyboard device, but some devices
emulate keyboards for other purposes. Most commonly, people run into
this with Yubikeys, so let's ignore those.

Even if we end up supporting multiple keyboards in the future, it's
safer to ignore known non-keyboard devices.

Signed-off-by: Hector Martin <[email protected]>
  • Loading branch information
marcan authored and kettenis committed Jan 8, 2024
1 parent 47e2a98 commit 18217cb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions common/usb_kbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ struct usb_kbd_pdata {

extern int __maybe_unused net_busy_flag;

/*
* Since we only support one usbkbd device in the iomux,
* ignore common keyboard-emulating devices that aren't
* real keyboards.
*/
const uint16_t vid_blocklist[] = {
0x1050, /* Yubico */
};

/* The period of time between two calls of usb_kbd_testc(). */
static unsigned long kbd_testc_tms;

Expand Down Expand Up @@ -465,6 +474,7 @@ static int usb_kbd_probe_dev(struct usb_device *dev, unsigned int ifnum)
struct usb_endpoint_descriptor *ep;
struct usb_kbd_pdata *data;
int epNum;
int i;

if (dev->descriptor.bNumConfigurations != 1)
return 0;
Expand All @@ -480,6 +490,15 @@ static int usb_kbd_probe_dev(struct usb_device *dev, unsigned int ifnum)
if (iface->desc.bInterfaceProtocol != USB_PROT_HID_KEYBOARD)
return 0;

for (i = 0; i < ARRAY_SIZE(vid_blocklist); i++) {
if (dev->descriptor.idVendor == vid_blocklist[i]) {
printf("Ignoring keyboard device 0x%x:0x%x\n",
dev->descriptor.idVendor,
dev->descriptor.idProduct);
return 0;
}
}

for (epNum = 0; epNum < iface->desc.bNumEndpoints; epNum++) {
ep = &iface->ep_desc[epNum];

Expand Down

0 comments on commit 18217cb

Please sign in to comment.