Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp5846724ybn; Sun, 29 Sep 2019 07:01:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyX9S25GtrlRCf7jseExFc4vpXp4gznI5W/HO7HAPcPEQMha6Turjnf6WOPK/biCk6qIIqA X-Received: by 2002:a17:906:3294:: with SMTP id 20mr15320860ejw.19.1569765662704; Sun, 29 Sep 2019 07:01:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569765662; cv=none; d=google.com; s=arc-20160816; b=YTo2wK9wDpabISllH+s0Jjo7jou2DpxJpMqfb/CP3zkC9E/Z2/uIOHpO+DOFClZU2W IxOYePzR4dsM3ww1shx871FuT5p6MC4OJggkEbJomY5AgSx0gS1RjS7Xt9Kp3BZNfFwJ UbRNeY+VXS8+IlTe8U4o9fjMOEzn0Jd/c1Aq4Ja4NL4oOj5mSnkq9NRqOzkRFb7U7x1+ 3uvAEp4P24EkuWavThfj9b/dpllSVg1CKUsxzGobVrcyuWLVykGtocQb7wkCWcgnQzKL SlBx2fvNAj2RlSf/fWzuFY2MU5PkxSsU2Wf5yPgXSlQbl49yAR9CVm82ILzcguJZU2YR Lgiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dZKxVELDFLaPjfHEl+kk8H8gvVk8+6wpfM6Eyv3KBgc=; b=ivGNxfShqGPRXgi0d1ADhxroe3YMhCicZB6J7+iBvQj29we05h+t+KkHB16NKwlxAb 3pJ831/IPwo9F7Y+fsEd20eGDLhqJGoQmXvM4eCsMMYrii1r1NdIxJ/0xVGm4eFXac7Z ygs27LwKGYElblFutLx2ro/sXia5C9ITJJBjUJlEite9uPRtg4HcPxYdr+NfLk5aAYYM Y2vqj/lkN/k9rlz3lwem1IPEL+l/IIfNnKLfgwTgyyz7oiB0YgtgSh2dece+OVLEfZLe VAFkw+1OreNmPW3LRLidJxJwb+lTvvZnSSX5b1cevWQrTFQhZsMTSEzEjrmUNsYz7qX2 35aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Sw5juGp7; 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 g11si5662847ejc.366.2019.09.29.07.00.38; Sun, 29 Sep 2019 07:01:02 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Sw5juGp7; 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 S1729212AbfI2N5V (ORCPT + 99 others); Sun, 29 Sep 2019 09:57:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:37570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729195AbfI2N5S (ORCPT ); Sun, 29 Sep 2019 09:57:18 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 DBF8521882; Sun, 29 Sep 2019 13:57:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569765437; bh=U/xQk/O39tGlQl/7kP1ZY7R0dx9/CTG4sHjuJmqXJ0Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sw5juGp7EPk0MT8ER4OHrYf99sMvtfxta/1BGIGcP/kjI5Inmd2MJSqmJ4s5xe3tA qJvYYwjfvQnlowOqA2TDBLUDdNLHmkPHUKYlqickMTmXlgDZ1PQ5BOBZAq5Y89O6sm ao8TEQXXc8N3guEtAF2EzD18itik+fnFtRm0nmwk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Jiri Kosina , syzbot+1088533649dafa1c9004@syzkaller.appspotmail.com Subject: [PATCH 4.19 07/63] HID: prodikeys: Fix general protection fault during probe Date: Sun, 29 Sep 2019 15:53:40 +0200 Message-Id: <20190929135032.554173527@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190929135031.382429403@linuxfoundation.org> References: <20190929135031.382429403@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alan Stern commit 98375b86c79137416e9fd354177b85e768c16e56 upstream. The syzbot fuzzer provoked a general protection fault in the hid-prodikeys driver: 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 Code: 0f 85 50 04 00 00 48 8b 04 24 4c 89 7d 10 48 8b 58 08 e8 b2 53 e4 fc 48 8b 54 24 20 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 <80> 3c 02 00 0f 85 13 04 00 00 48 ba 00 00 00 00 00 fc ff df 49 8b The problem is caused by the fact that pcmidi_get_output_report() will return an error if the HID device doesn't provide the right sort of output report, but pcmidi_set_operational() doesn't bother to check the return code and assumes the function call always succeeds. This patch adds the missing check and aborts the probe operation if necessary. Reported-and-tested-by: syzbot+1088533649dafa1c9004@syzkaller.appspotmail.com Signed-off-by: Alan Stern CC: Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/hid/hid-prodikeys.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/drivers/hid/hid-prodikeys.c +++ b/drivers/hid/hid-prodikeys.c @@ -555,10 +555,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; } @@ -687,7 +691,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);