From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99074C2D0C6 for ; Wed, 11 Dec 2019 14:18:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 64A7B21556 for ; Wed, 11 Dec 2019 14:18:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576073900; bh=+H4MGUo0gC4uetQ+rmXNbqxXzXtjav/zslpd/VoejfI=; h=Date:From:To:cc:Subject:In-Reply-To:References:List-ID:From; b=C9LnBLAd9A3I/0tuWe7wXmeNx4ioCx6pizFjmn+Aq46ZJ2aiZj4creTlK22946gKb OJoF4Z+Fy3RtWqWE7+3tU8k31Vp7trzSq17iG83BzDTrNm0PUjOD1GYJ+kbO7+KxxX wdEnEqzp3FsJZ0kbpRX+YOSB0dmPbaYyaUe7I/7E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729823AbfLKOST (ORCPT ); Wed, 11 Dec 2019 09:18:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:57264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729671AbfLKOST (ORCPT ); Wed, 11 Dec 2019 09:18:19 -0500 Received: from pobox.suse.cz (prg-ext-pat.suse.com [213.151.95.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ED51F214AF; Wed, 11 Dec 2019 14:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576073899; bh=+H4MGUo0gC4uetQ+rmXNbqxXzXtjav/zslpd/VoejfI=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=U/4wOD/HWDijvXYTZYe/fGkWMDDh/8J1ohOQn/O2hHQSyj5axQ5Tdt6TNUzFKr2En tfRrTv9mwnIjhWVyWkU0Z//81RgrgFPyBH40ouF2uQ6m/utkzh77mT0hKqhroUo2qD oqB7RDJmcW3EHtMH9k7QNn+lar2neL8dcuHYdB8Q= Date: Wed, 11 Dec 2019 15:18:15 +0100 (CET) From: Jiri Kosina To: Alan Stern cc: Benjamin Tissoires , linux-input@vger.kernel.org, USB list , syzkaller-bugs Subject: Re: [PATCH] HID: Fix slab-out-of-bounds read in hid_field_extract In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Tue, 10 Dec 2019, Alan Stern wrote: > The syzbot fuzzer found a slab-out-of-bounds bug in the HID report > handler. The bug was caused by a report descriptor which included a > field with size 12 bits and count 4899, for a total size of 7349 > bytes. > > The usbhid driver uses at most a single-page 4-KB buffer for reports. > In the test there wasn't any problem about overflowing the buffer, > since only one byte was received from the device. Rather, the bug > occurred when the HID core tried to extract the data from the report > fields, which caused it to try reading data beyond the end of the > allocated buffer. > > This patch fixes the problem by rejecting any report whose total > length exceeds the HID_MAX_BUFFER_SIZE limit (minus one byte to allow > for a possible report index). In theory a device could have a report > longer than that, but if there was such a thing we wouldn't handle it > correctly anyway. > > Reported-and-tested-by: syzbot+09ef48aa58261464b621@syzkaller.appspotmail.com > Signed-off-by: Alan Stern > CC: Thanks for hunting this down Alan. Applied. -- Jiri Kosina SUSE Labs