lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.44L0.1912091448420.1462-100000@iolanthe.rowland.org>
Date:   Mon, 9 Dec 2019 14:51:41 -0500 (EST)
From:   Alan Stern <stern@...land.harvard.edu>
To:     syzbot <syzbot+09ef48aa58261464b621@...kaller.appspotmail.com>
cc:     andreyknvl@...gle.com, <benjamin.tissoires@...hat.com>,
        <jikos@...nel.org>, <linux-input@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <linux-usb@...r.kernel.org>,
        <syzkaller-bugs@...glegroups.com>
Subject: Re: KASAN: slab-out-of-bounds Read in hid_field_extract

On Mon, 9 Dec 2019, syzbot wrote:

> Hello,
> 
> syzbot has tested the proposed patch but the reproducer still triggered  
> crash:
> KASAN: slab-out-of-bounds Read in hid_field_extract
> 
> microsoft 0003:045E:07DA.0001: Report rsize 4096 csize 1
> microsoft 0003:045E:07DA.0001: Field offset 0 size 12 count 4899
> ==================================================================
> BUG: KASAN: slab-out-of-bounds in __extract drivers/hid/hid-core.c:1345  
> [inline]
> BUG: KASAN: slab-out-of-bounds in hid_field_extract+0x150/0x170  
> drivers/hid/hid-core.c:1365
> Read of size 1 at addr ffff8881cc759000 by task swapper/1/0

Nobody bothers to check for ridiculously long reports?  This field had 
report_size = 12 and report_count = 4899!

Alan Stern

#syz test: https://github.com/google/kasan.git 1f22d15c

Index: usb-devel/drivers/hid/hid-core.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-core.c
+++ usb-devel/drivers/hid/hid-core.c
@@ -267,6 +267,10 @@ static int hid_add_field(struct hid_pars
 
 	offset = report->size;
 	report->size += parser->global.report_size * parser->global.report_count;
+	if (report->size > HID_MAX_BUFFER_SIZE << 3) {
+		hid_err(parser->device, "report is too long\n");
+		return -1;
+	}
 
 	if (!parser->local.usage_index) /* Ignore padding fields */
 		return 0;
@@ -1488,6 +1492,7 @@ static void hid_input_field(struct hid_d
 	if (!value)
 		return;
 
+	hid_info(hid, "Field offset %u size %u count %u\n", offset, size, count);
 	for (n = 0; n < count; n++) {
 
 		value[n] = min < 0 ?
@@ -1712,6 +1717,7 @@ int hid_report_raw_event(struct hid_devi
 	}
 
 	if (hid->claimed != HID_CLAIMED_HIDRAW && report->maxfield) {
+		hid_info(hid, "Report rsize %u csize %u\n", rsize, csize);
 		for (a = 0; a < report->maxfield; a++)
 			hid_input_field(hid, report->field[a], cdata, interrupt);
 		hdrv = hid->driver;



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ