Skip to content

Commit a699164

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 1369bb5 commit a699164

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
@@ -464,7 +464,10 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
464464

465465
case HID_GLOBAL_ITEM_TAG_REPORT_SIZE:
466466
parser->global.report_size = item_udata(item);
467-
if (parser->global.report_size > 256) {
467+
/* Arbitrary maximum. Some Apple devices have 16384 here.
468+
* This * HID_MAX_USAGES must fit in a signed integer.
469+
*/
470+
if (parser->global.report_size > 16384) {
468471
hid_err(parser->device, "invalid report_size %d\n",
469472
parser->global.report_size);
470473
return -1;

0 commit comments

Comments
 (0)