Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2414981ybe; Tue, 3 Sep 2019 12:30:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhvwUSea6O4JtyGr9f8O1IeCc4kuste2pEAxsNEMU9DOoWoZJNpd/3cjsxFiiUL+93BHSQ X-Received: by 2002:a63:a011:: with SMTP id r17mr8914907pge.219.1567539010699; Tue, 03 Sep 2019 12:30:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567539010; cv=none; d=google.com; s=arc-20160816; b=cSxBdd96EOcuhySQhFWmh+n2+ZC5aVzm4+S6TP/0JahbGb04x5CHUumkiOLA+4Ldk8 HKBqWJP/xrcI6PGRl/yuUBQ4G83mnmY+fP8+FsERDCdgRabyKwj6XiHzA93Pyhi08+21 2L4Gm6XMhfUXdudxLfiaqm5pvw0bRpqJgnNlG30x06XKFPU+lenFNuLZXkHb8uT+qmdK +b+db8ZsheprvyA6b3I2cu7GUmF38BPqPLs3Dqr4JRxNy5DGGB2pEcnyhTBEVTixVJ/4 pAD9KZ0cwZu3+ZkoN0iya5PZi76ZavPK9fFcDQHyvK8RWWMvsri3VKLw5HQ3N4EeJ1GS OhAg== 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=zcK6JmquRvcGU6McQkSyEgQk9oMVyqe0RQcZIyXE8C8=; b=dmK/ORZj3h/pNjBBA+jeXe/0tuRBdD/7Jcyjvj06piZhh5vU+CsorQiwElpf9jCSP+ auecKnFSfuj3hW1gSp5czq1uRiWKq5INd/8o4/rFvr5azi1kyRFvIZHMChUCi5Y6Lost lO9a7ds+TD+FHSD/d7wGR6kkqHLKWILAFCEEyu+iYjIbYPvC5/aR3TlV+1tR7l4z53Rn JBWgi3OX/+SZCqs/iCKwKKg5KTaFoGSHN2++DK5+DyNhNWxQE/JhQJoJVkUxBLSzWfsq JbuzPX/MwxV3c/pPDoB6B3hM2zsbf7NI2ZNwY4EUckZidUgO6YzWn21fQXzM0Glv8P+U Zarg== 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 l13si15556798pgp.133.2019.09.03.12.29.55; Tue, 03 Sep 2019 12:30:10 -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 S1726784AbfICT1v (ORCPT + 99 others); Tue, 3 Sep 2019 15:27:51 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:33638 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1725977AbfICT1u (ORCPT ); Tue, 3 Sep 2019 15:27:50 -0400 Received: (qmail 7544 invoked by uid 2102); 3 Sep 2019 15:27:49 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 3 Sep 2019 15:27:49 -0400 Date: Tue, 3 Sep 2019 15:27:49 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: syzbot cc: andreyknvl@google.com, , , , , , Subject: Re: general protection fault in pk_probe In-Reply-To: <0000000000002725f40591a4f118@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 Tue, 3 Sep 2019, syzbot wrote: > Hello, > > syzbot found the following crash on: > > HEAD commit: eea39f24 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=14c3589e600000 > kernel config: https://syzkaller.appspot.com/x/.config?x=d0c62209eedfd54e > dashboard link: https://syzkaller.appspot.com/bug?extid=1088533649dafa1c9004 > compiler: gcc (GCC) 9.0.0 20181231 (experimental) > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1667cc66600000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10f30dbc600000 > > IMPORTANT: if you fix the bug, please add the following tag to the commit: > Reported-by: syzbot+1088533649dafa1c9004@syzkaller.appspotmail.com > > prodikeys 0003:041E:2801.0001: unknown main item tag 0x0 > prodikeys 0003:041E:2801.0001: unknown main item tag 0x0 > prodikeys 0003:041E:2801.0001: hidraw0: USB HID v0.00 Device [HID > 041e:2801] on usb-dummy_hcd.0-1/input1 > kasan: CONFIG_KASAN_INLINE enabled > kasan: GPF could be caused by NULL-ptr deref or user memory access > general protection fault: 0000 [#1] SMP KASAN > CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.3.0-rc5+ #28 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS > Google 01/01/2011 > Workqueue: usb_hub_wq hub_event > RIP: 0010:pcmidi_submit_output_report drivers/hid/hid-prodikeys.c:300 > [inline] > RIP: 0010:pcmidi_set_operational drivers/hid/hid-prodikeys.c:558 [inline] > RIP: 0010:pcmidi_snd_initialise drivers/hid/hid-prodikeys.c:686 [inline] > RIP: 0010:pk_probe+0xb51/0xfd0 drivers/hid/hid-prodikeys.c:836 The reason for this bug seems pretty clear: pcmidi_get_output_report() can return an error, but pcmidi_set_operational() doesn't bother to check the return code. Alan Stern #syz test: https://github.com/google/kasan.git eea39f24 Index: usb-devel/drivers/hid/hid-prodikeys.c =================================================================== --- usb-devel.orig/drivers/hid/hid-prodikeys.c +++ usb-devel/drivers/hid/hid-prodikeys.c @@ -551,10 +551,14 @@ static void pcmidi_setup_extra_keys( static int pcmidi_set_operational(struct pcmidi_snd *pm) { + int rc; + if (pm->ifnum != 1) return 0; /* only set up ONCE for interace 1 */ - pcmidi_get_output_report(pm); + rc = pcmidi_get_output_report(pm); + if (rc < 0) + return rc; pcmidi_submit_output_report(pm, 0xc1); return 0; } @@ -683,7 +687,11 @@ static int pcmidi_snd_initialise(struct spin_lock_init(&pm->rawmidi_in_lock); init_sustain_timers(pm); - pcmidi_set_operational(pm); + err = pcmidi_set_operational(pm); + if (err < 0) { + pk_error("failed to find output report\n"); + goto fail_register; + } /* register it */ err = snd_card_register(card);