HID: wacom: reject short input reports
Subsystems (2)
PATCH 1/1 HID: wacom: reject short input reports
wacom_raw_event() passes incoming reports to the pen serial extractor and the device-specific IRQ parsers before the HID core validates the declared report length. A short report can therefore make either consumer read past the valid input data.
Require the complete report described by the HID report descriptor before invoking either parser.
--- drivers/hid/wacom_sys.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hid/wacom_sys.c +3 -0
@@ -175,6 +175,9 @@ static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,if (wacom->wacom_wac.features.type ==BOOTLOADER )return 0 ; +if (size <hid_report_len (report)) +return 0 ; +if (wacom_wac_pen_serial_enforce (hdev, report, raw_data, size))return -1 ;
Signature · 1 line
2.34.1
Quoted 8 lines · Jiale Yao
wacom_raw_event()passes incoming reports to the pen serial extractor and the device-specific IRQ parsers before the HID core validates the declared report length. A short report can therefore make either consumer read past the valid input data.Require the complete report described by the HID report descriptor before invoking either parser.
Quoted 21 lines
Signed-off-by Jiale Yao <[email protected]>---
drivers/hid/wacom_sys.c| 3 +++1 file changed, 3 insertions(+)drivers/hid/wacom_sys.c +3
-0@@ -175,6 +175,9 @@ static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,if (wacom->wacom_wac.features.type ==BOOTLOADER )return 0 ; +if (size <hid_report_len (report)) +return 0 ; +if (wacom_wac_pen_serial_enforce (hdev, report, raw_data, size))return -1 ;Signature · 1 line
2.34.1
Jason Gerecke
Acked-byQuoted 27 lines · jiale yao
Quoted 8 lines · Jiale Yao
wacom_raw_event()passes incoming reports to the pen serial extractor and the device-specific IRQ parsers before the HID core validates the declared report length. A short report can therefore make either consumer read past the valid input data.Require the complete report described by the HID report descriptor before invoking either parser.
Fixes 29b4739134c7 ("Input: wacom - switch from an USB driver to a HID driver")Fixes 83417206427b ("HID: wacom: Queue events with missing type/serial data for later processing")Quoted 13 lines
Signed-off-by Jiale Yao <[email protected]>---
drivers/hid/wacom_sys.c| 3 +++1 file changed, 3 insertions(+)drivers/hid/wacom_sys.c +0
-0@@ -175,6 +175,9 @@ static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,if (wacom->wacom_wac.features.type ==BOOTLOADER )return 0 ;
Quoted 3 lines
drivers/hid/wacom_sys.c static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, · line 180
Quoted 3 lines
drivers/hid/wacom_sys.c +3
-0+if (size <hid_report_len (report)) +return 0 ; +
This seems reasonable enough. The hid-core.c:hid_report_raw_event extends the short reports with zeroes and then processes the result, but that's not safe to do here without making our own copy of raw_data (because we don't know how large the underlying buffer actually is). But copying seems like overkill since I doubt that our hardware produces such short events (based on the lack of reported irq function misbehaviors). Returning early seems like a perfectly reasonable reaction if this ever occurs (e.g. by mocked-up uhid devices or usb gadgets).
I'm slightly hesitant to give a full reviewed-by given that this is just an assumption (and one that we can't reasonably test given how many different kinds of devices might be impacted), but I'm happy to ack the patch.
Jason (she/they)
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one /
(That is to say, eight) to the two, /
But you can’t take seven from three, /
So you look at the sixty-fours....
Quoted 5 lines
Quoted 5 lines
drivers/hid/wacom_sys.c +0
-1if (wacom_wac_pen_serial_enforce (hdev, report, raw_data, size))return -1 ; --2.34.1
Quoted 18 lines · Jiale Yao
wacom_raw_event()passes incoming reports to the pen serial extractor and the device-specific IRQ parsers before the HID core validates the declared report length. A short report can therefore make either consumer read past the valid input data.Require the complete report described by the HID report descriptor before invoking either parser.
Signed-off-by Jiale Yao <[email protected]>--- drivers/hid/wacom_sys.c | 3 +++ 1 file changed, 3 insertions(+)drivers/hid/wacom_sys.c +0
-0
drivers/hid/wacom_sys.c static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, · line 182
Quoted 8 lines
drivers/hid/wacom_sys.c +3
-0@@ -175,6 +175,9 @@ static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,if (wacom->wacom_wac.features.type ==BOOTLOADER )return 0 ; +if (size <hid_report_len (report)) +return 0 ; +if (wacom_wac_pen_serial_enforce (hdev, report, raw_data, size))return -1 ;
Applied, thanks.
Signature · 2 lines
Jiri Kosina SUSE Labs