Skip to content

Commit 092150a

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
Pull HID fixes from Jiri Kosina: - spectrev1 pattern fix in hiddev from Gustavo A. R. Silva - bounds check fix for hid-debug from Daniel Rosenberg - regression fix for HID autobinding from Benjamin Tissoires - removal of excessive logging from i2c-hid driver from Jason Andryuk - fix specific to 2nd generation of Wacom Intuos devices from Jason Gerecke * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: HID: hiddev: fix potential Spectre v1 HID: i2c-hid: Fix "incomplete report" noise HID: wacom: Correct touch maximum XY of 2nd-gen Intuos HID: debug: check length before copy_to_user() HID: core: allow concurrent registration of drivers
2 parents bdf3311 + 4f65245 commit 092150a

File tree

6 files changed

+33
-6
lines changed

6 files changed

+33
-6
lines changed

drivers/hid/hid-core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1952,6 +1952,8 @@ static int hid_device_probe(struct device *dev)
19521952
}
19531953
hdev->io_started = false;
19541954

1955+
clear_bit(ffs(HID_STAT_REPROBED), &hdev->status);
1956+
19551957
if (!hdev->driver) {
19561958
id = hid_match_device(hdev, hdrv);
19571959
if (id == NULL) {
@@ -2215,7 +2217,8 @@ static int __hid_bus_reprobe_drivers(struct device *dev, void *data)
22152217
struct hid_device *hdev = to_hid_device(dev);
22162218

22172219
if (hdev->driver == hdrv &&
2218-
!hdrv->match(hdev, hid_ignore_special_drivers))
2220+
!hdrv->match(hdev, hid_ignore_special_drivers) &&
2221+
!test_and_set_bit(ffs(HID_STAT_REPROBED), &hdev->status))
22192222
return device_reprobe(dev);
22202223

22212224
return 0;

drivers/hid/hid-debug.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,8 @@ static ssize_t hid_debug_events_read(struct file *file, char __user *buffer,
11541154
goto out;
11551155
if (list->tail > list->head) {
11561156
len = list->tail - list->head;
1157+
if (len > count)
1158+
len = count;
11571159

11581160
if (copy_to_user(buffer + ret, &list->hid_debug_buf[list->head], len)) {
11591161
ret = -EFAULT;
@@ -1163,14 +1165,18 @@ static ssize_t hid_debug_events_read(struct file *file, char __user *buffer,
11631165
list->head += len;
11641166
} else {
11651167
len = HID_DEBUG_BUFSIZE - list->head;
1168+
if (len > count)
1169+
len = count;
11661170

11671171
if (copy_to_user(buffer, &list->hid_debug_buf[list->head], len)) {
11681172
ret = -EFAULT;
11691173
goto out;
11701174
}
11711175
list->head = 0;
11721176
ret += len;
1173-
goto copy_rest;
1177+
count -= len;
1178+
if (count > 0)
1179+
goto copy_rest;
11741180
}
11751181

11761182
}

drivers/hid/i2c-hid/i2c-hid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ static void i2c_hid_get_input(struct i2c_hid *ihid)
484484
return;
485485
}
486486

487-
if ((ret_size > size) || (ret_size <= 2)) {
487+
if ((ret_size > size) || (ret_size < 2)) {
488488
dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n",
489489
__func__, size, ret_size);
490490
return;

drivers/hid/usbhid/hiddev.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <linux/hiddev.h>
3737
#include <linux/compat.h>
3838
#include <linux/vmalloc.h>
39+
#include <linux/nospec.h>
3940
#include "usbhid.h"
4041

4142
#ifdef CONFIG_USB_DYNAMIC_MINORS
@@ -469,10 +470,14 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd,
469470

470471
if (uref->field_index >= report->maxfield)
471472
goto inval;
473+
uref->field_index = array_index_nospec(uref->field_index,
474+
report->maxfield);
472475

473476
field = report->field[uref->field_index];
474477
if (uref->usage_index >= field->maxusage)
475478
goto inval;
479+
uref->usage_index = array_index_nospec(uref->usage_index,
480+
field->maxusage);
476481

477482
uref->usage_code = field->usage[uref->usage_index].hid;
478483

@@ -499,6 +504,8 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd,
499504

500505
if (uref->field_index >= report->maxfield)
501506
goto inval;
507+
uref->field_index = array_index_nospec(uref->field_index,
508+
report->maxfield);
502509

503510
field = report->field[uref->field_index];
504511

@@ -753,6 +760,8 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
753760

754761
if (finfo.field_index >= report->maxfield)
755762
break;
763+
finfo.field_index = array_index_nospec(finfo.field_index,
764+
report->maxfield);
756765

757766
field = report->field[finfo.field_index];
758767
memset(&finfo, 0, sizeof(finfo));
@@ -797,6 +806,8 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
797806

798807
if (cinfo.index >= hid->maxcollection)
799808
break;
809+
cinfo.index = array_index_nospec(cinfo.index,
810+
hid->maxcollection);
800811

801812
cinfo.type = hid->collection[cinfo.index].type;
802813
cinfo.usage = hid->collection[cinfo.index].usage;

drivers/hid/wacom_wac.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3365,8 +3365,14 @@ void wacom_setup_device_quirks(struct wacom *wacom)
33653365
if (features->type >= INTUOSHT && features->type <= BAMBOO_PT)
33663366
features->device_type |= WACOM_DEVICETYPE_PAD;
33673367

3368-
features->x_max = 4096;
3369-
features->y_max = 4096;
3368+
if (features->type == INTUOSHT2) {
3369+
features->x_max = features->x_max / 10;
3370+
features->y_max = features->y_max / 10;
3371+
}
3372+
else {
3373+
features->x_max = 4096;
3374+
features->y_max = 4096;
3375+
}
33703376
}
33713377
else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
33723378
features->device_type |= WACOM_DEVICETYPE_PAD;

include/linux/hid.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ struct hid_output_fifo {
511511
#define HID_STAT_ADDED BIT(0)
512512
#define HID_STAT_PARSED BIT(1)
513513
#define HID_STAT_DUP_DETECTED BIT(2)
514+
#define HID_STAT_REPROBED BIT(3)
514515

515516
struct hid_input {
516517
struct list_head list;
@@ -579,7 +580,7 @@ struct hid_device { /* device report descriptor */
579580
bool battery_avoid_query;
580581
#endif
581582

582-
unsigned int status; /* see STAT flags above */
583+
unsigned long status; /* see STAT flags above */
583584
unsigned claimed; /* Claimed by hidinput, hiddev? */
584585
unsigned quirks; /* Various quirks the device can pull on us */
585586
bool io_started; /* If IO has started */

0 commit comments

Comments
 (0)