Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5984106ybe; Tue, 17 Sep 2019 17:26:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIAGSFnxqdE5uwEMrVBCgIQcClKNVeHlV7cE2b4I1BG1oG2P5gZKzdsq7RwffEWq/vP1Va X-Received: by 2002:a50:d556:: with SMTP id f22mr7340000edj.263.1568766390679; Tue, 17 Sep 2019 17:26:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568766390; cv=none; d=google.com; s=arc-20160816; b=F+EH8WauUP4C6+trJFR3FLObcaSjxkiDmnICnv3FUNximoAv6AouB0S/yjCohOvqq0 OOcOj/JecT5Xy5pqSN+A4lsFeAGhcpwzEfJTukD9HOvilLSXOJgxOHfHoU0HwRw1N/pi X2vdSyp2O0dthB4pZfXj0HEQMpfWJGL+yO8BzliezTN/9BPS4+i1NWkOmI2TPCK9wKt7 ciRNdZGu2oGExhyt0kntsuUIH3+p2NZrvYcjX/1K27Q6bQlCTzxB1/9hl/AdCdx5erSD loUYa1Rc8etFofJVQcL2YfY7KrWBptH6OCJCWohK2Pi4abfomA/N+KpxGtcTyt4hYY31 PtVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=Tx/o+ECt7TMPFWkQGXD/a3n29BxTXxJXRq1qlTr4NMU=; b=c6OVAVIYegzHnOSggUxu3ycRUdJ71Z4qOkiEYL0Fs+FnC38eXEomS6s/5RhWxTDqB+ DudtoMaSnhp/L9//FEJEN62r9BOjQyTTRf4d2UxAisVGOSd5erq0hytr9lVnDI96AKrG MZ5r0bNgdj1V2AoS5xR7VjJtSgfYLR+e42463+fXsMbwxDfqs0DSeePlsUwq433RRNLb uRpaPfSZza8OQcvKDbwY6lN8B/UqfEOLqAwbrNdbSrfrVrgyMdz51b4uXWkNBLuU5djl mBufBl3S+QOg2aaHrcZYcKeg4wrOypahZ6GKGHUhnHT7OUkhGf2Hc28fVXWqibbdwgSE 7l9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q16si2072119ejm.267.2019.09.17.17.26.07; Tue, 17 Sep 2019 17:26:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729182AbfIQSYw (ORCPT + 99 others); Tue, 17 Sep 2019 14:24:52 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:39220 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1729148AbfIQSYw (ORCPT ); Tue, 17 Sep 2019 14:24:52 -0400 Received: (qmail 6810 invoked by uid 2102); 17 Sep 2019 14:24:51 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 17 Sep 2019 14:24:51 -0400 Date: Tue, 17 Sep 2019 14:24:51 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: syzbot cc: andreyknvl@google.com, , , , , , Subject: Re: KASAN: slab-out-of-bounds Write in ga_probe In-Reply-To: <000000000000cd1def0592ab9697@google.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 16 Sep 2019, syzbot wrote: > Hello, > > syzbot found the following crash on: > > HEAD commit: f0df5c1b usb-fuzzer: main usb gadget fuzzer driver > git tree: https://github.com/google/kasan.git usb-fuzzer > console output: https://syzkaller.appspot.com/x/log.txt?x=14045831600000 > kernel config: https://syzkaller.appspot.com/x/.config?x=5c6633fa4ed00be5 > dashboard link: https://syzkaller.appspot.com/bug?extid=403741a091bf41d4ae79 > compiler: gcc (GCC) 9.0.0 20181231 (experimental) > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13c1e62d600000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=166a3a95600000 > > IMPORTANT: if you fix the bug, please add the following tag to the commit: > Reported-by: syzbot+403741a091bf41d4ae79@syzkaller.appspotmail.com > > usb 1-1: config 0 interface 0 altsetting 0 has 1 endpoint descriptor, > different from the interface descriptor's value: 9 > usb 1-1: New USB device found, idVendor=0e8f, idProduct=0012, bcdDevice= > 0.00 > usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 > usb 1-1: config 0 descriptor?? > greenasia 0003:0E8F:0012.0001: unknown main item tag 0x0 > greenasia 0003:0E8F:0012.0001: hidraw0: USB HID v0.00 Device [HID > 0e8f:0012] on usb-dummy_hcd.0-1/input0 > ================================================================== > BUG: KASAN: slab-out-of-bounds in set_bit > include/asm-generic/bitops-instrumented.h:28 [inline] > BUG: KASAN: slab-out-of-bounds in gaff_init drivers/hid/hid-gaff.c:97 > [inline] > BUG: KASAN: slab-out-of-bounds in ga_probe+0x1fd/0x6f0 > drivers/hid/hid-gaff.c:146 > Write of size 8 at addr ffff8881d9acafc0 by task kworker/1:1/78 > > CPU: 1 PID: 78 Comm: kworker/1:1 Not tainted 5.3.0-rc7+ #0 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS > Google 01/01/2011 > Workqueue: usb_hub_wq hub_event > Call Trace: > __dump_stack lib/dump_stack.c:77 [inline] > dump_stack+0xca/0x13e lib/dump_stack.c:113 > print_address_description+0x6a/0x32c mm/kasan/report.c:351 > __kasan_report.cold+0x1a/0x33 mm/kasan/report.c:482 > kasan_report+0xe/0x12 mm/kasan/common.c:618 > check_memory_region_inline mm/kasan/generic.c:185 [inline] > check_memory_region+0x128/0x190 mm/kasan/generic.c:192 > set_bit include/asm-generic/bitops-instrumented.h:28 [inline] > gaff_init drivers/hid/hid-gaff.c:97 [inline] > ga_probe+0x1fd/0x6f0 drivers/hid/hid-gaff.c:146 > hid_device_probe+0x2be/0x3f0 drivers/hid/hid-core.c:2209 > really_probe+0x281/0x6d0 drivers/base/dd.c:548 > driver_probe_device+0x101/0x1b0 drivers/base/dd.c:721 > __device_attach_driver+0x > > > --- > This bug is generated by a bot. It may contain errors. > See https://goo.gl/tpsmEJ for more information about syzbot. > syzbot engineers can be reached at syzkaller@googlegroups.com. > > syzbot will keep track of this bug report. See: > https://goo.gl/tpsmEJ#status for how to communicate with syzbot. > syzbot can test patches for this bug, for details see: > https://goo.gl/tpsmEJ#testing-patches The driver assumes that the device contains an input. Alan Stern https://github.com/google/kasan.git f0df5c1b drivers/hid/hid-gaff.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) Index: usb-devel/drivers/hid/hid-gaff.c =================================================================== --- usb-devel.orig/drivers/hid/hid-gaff.c +++ usb-devel/drivers/hid/hid-gaff.c @@ -64,14 +64,20 @@ static int gaff_init(struct hid_device * { struct gaff_device *gaff; struct hid_report *report; - struct hid_input *hidinput = list_entry(hid->inputs.next, - struct hid_input, list); + struct hid_input *hidinput; struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; struct list_head *report_ptr = report_list; - struct input_dev *dev = hidinput->input; + struct input_dev *dev; int error; + if (list_empty(&hid->inputs)) { + hid_err(hid, "no inputs found\n"); + return -ENODEV; + } + hidinput = list_entry(hid->inputs.next, struct hid_input, list); + dev = hidinput->input; + if (list_empty(report_list)) { hid_err(hid, "no output reports found\n"); return -ENODEV;