Skip to content

Commit 78d80fa

Browse files
marcanjannau
authored andcommitted
HID: Bump maximum report size to 16384
This maximum is arbitrary. Recent Apple devices have some vendor-defined reports with 16384 here which fail to parse without this, so let's bump it to that. This value is used as follows: report->size += parser->global.report_size * parser->global.report_count; [...] /* Total size check: Allow for possible report index byte */ if (report->size > (max_buffer_size - 1) << 3) { hid_err(parser->device, "report is too long\n"); return -1; } All of these fields are unsigned integers, and report_count is bounded by HID_MAX_USAGES (12288). Therefore, as long as the respective maximums do not overflow an unsigned integer (let's say a signed integer just in case), we're safe. This holds for 16384. Signed-off-by: Hector Martin <marcan@marcan.st>
1 parent 0c27be5 commit 78d80fa

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/hid/hid-core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,10 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
436436

437437
case HID_GLOBAL_ITEM_TAG_REPORT_SIZE:
438438
parser->global.report_size = item_udata(item);
439-
if (parser->global.report_size > 256) {
439+
/* Arbitrary maximum. Some Apple devices have 16384 here.
440+
* This * HID_MAX_USAGES must fit in a signed integer.
441+
*/
442+
if (parser->global.report_size > 16384) {
440443
hid_err(parser->device, "invalid report_size %d\n",
441444
parser->global.report_size);
442445
return -1;

0 commit comments

Comments
 (0)