Skip to content

Commit ce6a46c

Browse files
committed
HID: pass the buffer size to hid_report_raw_event
commit 0a3fe972a7cb ("HID: core: Mitigate potential OOB by removing bogus memset()") enforced the provided data to be at least the size of the declared buffer in the report descriptor to prevent a buffer overflow. However, we can try to be smarter by providing both the buffer size and the data size, meaning that hid_report_raw_event() can make better decision whether we should plaining reject the buffer (buffer overflow attempt) or if we can safely memset it to 0 and pass it to the rest of the stack. Fixes: 0a3fe972a7cb ("HID: core: Mitigate potential OOB by removing bogus memset()") Cc: stable@vger.kernel.org Signed-off-by: Benjamin Tissoires <bentiss@kernel.org> Acked-by: Johan Hovold <johan@kernel.org> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Jiri Kosina <jkosina@suse.com> [pedarkasy@gmail.com: Imported into input-wacom (2c85c61d1332)] Signed-off-by: Kori <pedarkasy@gmail.com>
1 parent 116fa15 commit ce6a46c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

4.18/wacom_sys.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static void wacom_wac_queue_flush(struct hid_device *hdev,
9696
kfree(buf);
9797
continue;
9898
}
99-
err = hid_report_raw_event(hdev, HID_INPUT_REPORT, buf, size, false);
99+
err = hid_report_raw_event(hdev, HID_INPUT_REPORT, buf, size, size, false);
100100
if (err) {
101101
hid_warn(hdev, "%s: unable to flush event due to error %d\n",
102102
__func__, err);
@@ -340,7 +340,7 @@ static void wacom_feature_mapping(struct hid_device *hdev,
340340
data, n, WAC_CMD_RETRIES);
341341
if (ret == n && features->type == HID_GENERIC) {
342342
ret = hid_report_raw_event(hdev,
343-
HID_FEATURE_REPORT, data, n, 0);
343+
HID_FEATURE_REPORT, data, n, n, 0);
344344
} else if (ret == 2 && features->type != HID_GENERIC) {
345345
features->touch_max = data[1];
346346
} else {
@@ -401,7 +401,7 @@ static void wacom_feature_mapping(struct hid_device *hdev,
401401
data, n, WAC_CMD_RETRIES);
402402
if (ret == n) {
403403
ret = hid_report_raw_event(hdev, HID_FEATURE_REPORT,
404-
data, n, 0);
404+
data, n, n, 0);
405405
} else {
406406
hid_warn(hdev, "%s: could not retrieve sensor offsets\n",
407407
__func__);

0 commit comments

Comments
 (0)