From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B7CA2BCF7F; Tue, 25 Aug 2026 13:31:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787664709; cv=none; b=E9vydQsVOe2KhhPr+PV+Vq83+6me29YbAQFwFJCGee7HK7mhX5oAOkVau8GvCV3Zd+/GM9K5URvXRibgM6WDSq8NepejaD+3Yl3oYhI04pHFyKaAHPW5uccqJExQ2PCvYjjQB5Ft4nnIYjXhj+uA7dTE5KsljLi0SHTjTIT3lS0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787664709; c=relaxed/simple; bh=U2JPnZQNnuVvkqBvObZKxeu3vpfTPHgcwiF6OlAuFYM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VontfmNgUUO3E2g2VvBVJzNIuBPnJ4tp/dDHGtsqu0rJY31oIdTiHOZ7m7nGb6lluYH5djRGTfjM4G1wEpGFPpLDrwz+DBBo+u7Xz8ftF4/7DMhxPVFGk6lQyMcv3S83M/GIqorB0+FSt6CLIImDOU5LSs26L2T2JMBuchDwkQg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IYijkxM/; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="IYijkxM/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 757D61F000E9; Tue, 25 Aug 2026 13:31:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787664708; bh=3cpewrsCEkukRQ5PqDS5NiDQXKrU4eDiIXSgHiAbd5U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IYijkxM/sjtsXKnnRF+24r/5EdQ1sizHg3LuiTmoKRhGG+x9GH8X10YlSW4HBwHgH Uq0zMnrM4ScYNCjRwluOZn3jKIvXoDDetBcQHX/hibfh8nkV7LAmjb5m8otWQgyce6 OJWeJPhPwOyML+Cmiz40ZNjUnXhwtz0e/f9Tw7aI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Federico Kirschbaum , Baul Lee , Jiri Kosina Subject: [PATCH 7.2 60/82] HID: core: fix OOB read of field->usage in hid_set_field() Date: Tue, 25 Aug 2026 15:25:47 +0200 Message-ID: <20260825132543.878609001@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260825132541.560541185@linuxfoundation.org> References: <20260825132541.560541185@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Baul Lee commit a13cdb19fcb223ed41bdab3bab42b98dba87e90b upstream. hid_set_field() hands field->usage + offset to hid_dump_input() before the guard that bounds offset: hid_dump_input(field->report->device, field->usage + offset, value); if (offset >= field->report_count) { hid_err(...); return -1; } Under CONFIG_DEBUG_FS hid_dump_input() dereferences that pointer, with buf = hid_resolv_usage(usage->hid, NULL). The usage[] array is allocated inline with the hid_field in hid_register_field() and holds field->maxusage entries, so an offset past it reads off the end of the kvzalloc()ed allocation and into a neighbouring object. Had the guard run first, offset < report_count <= maxusage would already have confined the pointer to the array. A caller supplies such an offset today. picolcd_fb_send_tile() validates only report->maxfield before issuing hid_set_field(report->field[0], 11 + i, ...) for i = 0..31, so its offsets are fixed at 11..42 and are never checked against the bound field. When the device registers that field with fewer usages, the framebuffer deferred-io work drives the read on every tile. KASAN reports a 4-byte slab-out-of-bounds read in hid_dump_input() below hid_set_field(), and the same boot logs "offset (1) exceeds report_count (1)" from the guard that runs only afterwards. Move the hid_dump_input() call below the guard. Because field->maxusage >= field->report_count, the guard then establishes that field->usage + offset lies inside the array before it is dereferenced, for every caller and without changing behaviour on the valid path. Discovered by XBOW, triaged by Baul Lee Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: Federico Kirschbaum Reported-by: Baul Lee Cc: stable@vger.kernel.org Signed-off-by: Baul Lee Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/hid/hid-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1933,13 +1933,14 @@ int hid_set_field(struct hid_field *fiel size = field->report_size; - hid_dump_input(field->report->device, field->usage + offset, value); - if (offset >= field->report_count) { hid_err(field->report->device, "offset (%d) exceeds report_count (%d)\n", offset, field->report_count); return -1; } + + hid_dump_input(field->report->device, field->usage + offset, value); + if (field->logical_minimum < 0) { if (value != snto32(s32ton(value, size), size)) { hid_err(field->report->device, "value %d is out of range\n", value);