Skip to content

Commit f0caa1d

Browse files
committed
Merge tag 'hid-for-linus-2026031701' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID fixes from Jiri Kosina: - various fixes dealing with (intentionally) broken devices in HID core, logitech-hidpp and multitouch drivers (Lee Jones) - fix for OOB in wacom driver (Benoît Sevens) - fix for potentialy HID-bpf-induced buffer overflow in () (Benjamin Tissoires) - various other small fixes and device ID / quirk additions * tag 'hid-for-linus-2026031701' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: HID: multitouch: Check to ensure report responses match the request HID: logitech-hidpp: Prevent use-after-free on force feedback initialisation failure HID: bpf: prevent buffer overflow in hid_hw_request selftests/hid: fix compilation when bpf_wq and hid_device are not exported HID: core: Mitigate potential OOB by removing bogus memset() HID: intel-thc-hid: Set HID_PHYS with PCI BDF HID: appletb-kbd: add .resume method in PM HID: logitech-hidpp: Enable MX Master 4 over bluetooth HID: input: Add HID_BATTERY_QUIRK_DYNAMIC for Elan touchscreens HID: input: Drop Asus UX550* touchscreen ignore battery quirks HID: asus: add xg mobile 2022 external hardware support HID: wacom: fix out-of-bounds read in wacom_intuos_bt_irq
2 parents 8a91ebb + e716eda commit f0caa1d

13 files changed

Lines changed: 61 additions & 15 deletions

File tree

drivers/hid/bpf/hid_bpf_dispatch.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz,
444444
(u64)(long)ctx,
445445
true); /* prevent infinite recursions */
446446

447+
if (ret > size)
448+
ret = size;
447449
if (ret > 0)
448450
memcpy(buf, dma_data, ret);
449451

drivers/hid/hid-appletb-kbd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ static int appletb_kbd_suspend(struct hid_device *hdev, pm_message_t msg)
476476
return 0;
477477
}
478478

479-
static int appletb_kbd_reset_resume(struct hid_device *hdev)
479+
static int appletb_kbd_resume(struct hid_device *hdev)
480480
{
481481
struct appletb_kbd *kbd = hid_get_drvdata(hdev);
482482

@@ -500,7 +500,8 @@ static struct hid_driver appletb_kbd_hid_driver = {
500500
.event = appletb_kbd_hid_event,
501501
.input_configured = appletb_kbd_input_configured,
502502
.suspend = pm_ptr(appletb_kbd_suspend),
503-
.reset_resume = pm_ptr(appletb_kbd_reset_resume),
503+
.resume = pm_ptr(appletb_kbd_resume),
504+
.reset_resume = pm_ptr(appletb_kbd_resume),
504505
.driver.dev_groups = appletb_kbd_groups,
505506
};
506507
module_hid_driver(appletb_kbd_hid_driver);

drivers/hid/hid-asus.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,9 @@ static const struct hid_device_id asus_devices[] = {
14971497
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
14981498
USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY_X),
14991499
QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD | QUIRK_ROG_ALLY_XPAD },
1500+
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1501+
USB_DEVICE_ID_ASUSTEK_XGM_2022),
1502+
},
15001503
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
15011504
USB_DEVICE_ID_ASUSTEK_XGM_2023),
15021505
},

drivers/hid/hid-core.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,9 +2057,10 @@ int hid_report_raw_event(struct hid_device *hid, enum hid_report_type type, u8 *
20572057
rsize = max_buffer_size;
20582058

20592059
if (csize < rsize) {
2060-
dbg_hid("report %d is too short, (%d < %d)\n", report->id,
2061-
csize, rsize);
2062-
memset(cdata + csize, 0, rsize - csize);
2060+
hid_warn_ratelimited(hid, "Event data for report %d was too short (%d vs %d)\n",
2061+
report->id, rsize, csize);
2062+
ret = -EINVAL;
2063+
goto out;
20632064
}
20642065

20652066
if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event)

drivers/hid/hid-ids.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
#define USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY_X 0x1b4c
230230
#define USB_DEVICE_ID_ASUSTEK_ROG_CLAYMORE_II_KEYBOARD 0x196b
231231
#define USB_DEVICE_ID_ASUSTEK_FX503VD_KEYBOARD 0x1869
232+
#define USB_DEVICE_ID_ASUSTEK_XGM_2022 0x1970
232233
#define USB_DEVICE_ID_ASUSTEK_XGM_2023 0x1a9a
233234

234235
#define USB_VENDOR_ID_ATEN 0x0557
@@ -454,8 +455,6 @@
454455
#define USB_DEVICE_ID_TOSHIBA_CLICK_L9W 0x0401
455456
#define USB_DEVICE_ID_HP_X2 0x074d
456457
#define USB_DEVICE_ID_HP_X2_10_COVER 0x0755
457-
#define USB_DEVICE_ID_ASUS_UX550VE_TOUCHSCREEN 0x2544
458-
#define USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN 0x2706
459458
#define I2C_DEVICE_ID_CHROMEBOOK_TROGDOR_POMPOM 0x2F81
460459

461460
#define USB_VENDOR_ID_ELECOM 0x056e

drivers/hid/hid-input.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ static enum power_supply_property hidinput_battery_props[] = {
354354
#define HID_BATTERY_QUIRK_FEATURE (1 << 1) /* ask for feature report */
355355
#define HID_BATTERY_QUIRK_IGNORE (1 << 2) /* completely ignore the battery */
356356
#define HID_BATTERY_QUIRK_AVOID_QUERY (1 << 3) /* do not query the battery */
357+
#define HID_BATTERY_QUIRK_DYNAMIC (1 << 4) /* report present only after life signs */
357358

358359
static const struct hid_device_id hid_battery_quirks[] = {
359360
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
@@ -386,10 +387,6 @@ static const struct hid_device_id hid_battery_quirks[] = {
386387
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH,
387388
USB_DEVICE_ID_LOGITECH_DINOVO_EDGE_KBD),
388389
HID_BATTERY_QUIRK_IGNORE },
389-
{ HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN),
390-
HID_BATTERY_QUIRK_IGNORE },
391-
{ HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ASUS_UX550VE_TOUCHSCREEN),
392-
HID_BATTERY_QUIRK_IGNORE },
393390
{ HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_L),
394391
HID_BATTERY_QUIRK_AVOID_QUERY },
395392
{ HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_MW),
@@ -402,8 +399,8 @@ static const struct hid_device_id hid_battery_quirks[] = {
402399
* Elan HID touchscreens seem to all report a non present battery,
403400
* set HID_BATTERY_QUIRK_IGNORE for all Elan I2C and USB HID devices.
404401
*/
405-
{ HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_IGNORE },
406-
{ HID_USB_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_IGNORE },
402+
{ HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_DYNAMIC },
403+
{ HID_USB_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_DYNAMIC },
407404
{}
408405
};
409406

@@ -460,11 +457,14 @@ static int hidinput_get_battery_property(struct power_supply *psy,
460457
int ret = 0;
461458

462459
switch (prop) {
463-
case POWER_SUPPLY_PROP_PRESENT:
464460
case POWER_SUPPLY_PROP_ONLINE:
465461
val->intval = 1;
466462
break;
467463

464+
case POWER_SUPPLY_PROP_PRESENT:
465+
val->intval = dev->battery_present;
466+
break;
467+
468468
case POWER_SUPPLY_PROP_CAPACITY:
469469
if (dev->battery_status != HID_BATTERY_REPORTED &&
470470
!dev->battery_avoid_query) {
@@ -577,6 +577,8 @@ static int hidinput_setup_battery(struct hid_device *dev, unsigned report_type,
577577
if (quirks & HID_BATTERY_QUIRK_AVOID_QUERY)
578578
dev->battery_avoid_query = true;
579579

580+
dev->battery_present = (quirks & HID_BATTERY_QUIRK_DYNAMIC) ? false : true;
581+
580582
dev->battery = power_supply_register(&dev->dev, psy_desc, &psy_cfg);
581583
if (IS_ERR(dev->battery)) {
582584
error = PTR_ERR(dev->battery);
@@ -632,6 +634,7 @@ static void hidinput_update_battery(struct hid_device *dev, unsigned int usage,
632634
return;
633635

634636
if (hidinput_update_battery_charge_status(dev, usage, value)) {
637+
dev->battery_present = true;
635638
power_supply_changed(dev->battery);
636639
return;
637640
}
@@ -647,6 +650,7 @@ static void hidinput_update_battery(struct hid_device *dev, unsigned int usage,
647650
if (dev->battery_status != HID_BATTERY_REPORTED ||
648651
capacity != dev->battery_capacity ||
649652
ktime_after(ktime_get_coarse(), dev->battery_ratelimit_time)) {
653+
dev->battery_present = true;
650654
dev->battery_capacity = capacity;
651655
dev->battery_status = HID_BATTERY_REPORTED;
652656
dev->battery_ratelimit_time =

drivers/hid/hid-logitech-hidpp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4487,10 +4487,12 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
44874487
if (!ret)
44884488
ret = hidpp_ff_init(hidpp, &data);
44894489

4490-
if (ret)
4490+
if (ret) {
44914491
hid_warn(hidpp->hid_dev,
44924492
"Unable to initialize force feedback support, errno %d\n",
44934493
ret);
4494+
ret = 0;
4495+
}
44944496
}
44954497

44964498
/*
@@ -4668,6 +4670,8 @@ static const struct hid_device_id hidpp_devices[] = {
46684670
HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb038) },
46694671
{ /* Slim Solar+ K980 Keyboard over Bluetooth */
46704672
HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb391) },
4673+
{ /* MX Master 4 mouse over Bluetooth */
4674+
HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb042) },
46714675
{}
46724676
};
46734677

drivers/hid/hid-multitouch.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,19 @@ static void mt_get_feature(struct hid_device *hdev, struct hid_report *report)
526526
dev_warn(&hdev->dev, "failed to fetch feature %d\n",
527527
report->id);
528528
} else {
529+
/* The report ID in the request and the response should match */
530+
if (report->id != buf[0]) {
531+
hid_err(hdev, "Returned feature report did not match the request\n");
532+
goto free;
533+
}
534+
529535
ret = hid_report_raw_event(hdev, HID_FEATURE_REPORT, buf,
530536
size, 0);
531537
if (ret)
532538
dev_warn(&hdev->dev, "failed to report feature\n");
533539
}
534540

541+
free:
535542
kfree(buf);
536543
}
537544

drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-hid.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ int quicki2c_hid_probe(struct quicki2c_device *qcdev)
127127
hid->product = le16_to_cpu(qcdev->dev_desc.product_id);
128128
snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X", "quicki2c-hid",
129129
hid->vendor, hid->product);
130+
strscpy(hid->phys, dev_name(qcdev->dev), sizeof(hid->phys));
130131

131132
ret = hid_add_device(hid);
132133
if (ret) {

drivers/hid/intel-thc-hid/intel-quickspi/quickspi-hid.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ int quickspi_hid_probe(struct quickspi_device *qsdev)
118118
hid->product = le16_to_cpu(qsdev->dev_desc.product_id);
119119
snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X", "quickspi-hid",
120120
hid->vendor, hid->product);
121+
strscpy(hid->phys, dev_name(qsdev->dev), sizeof(hid->phys));
121122

122123
ret = hid_add_device(hid);
123124
if (ret) {

0 commit comments

Comments
 (0)