Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp5854103ybn; Sun, 29 Sep 2019 07:07:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqyAGOYlCDztfQGWw+QJbt3tQPt3piYn8xh/j9IuotDeWbLQGJ3loXwC6DdmElLcTPIDeO6m X-Received: by 2002:a05:6402:1251:: with SMTP id l17mr14903940edw.270.1569766050396; Sun, 29 Sep 2019 07:07:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569766050; cv=none; d=google.com; s=arc-20160816; b=rpPfM1dHkDd4dIXiH8oRCB75FzNXWYDiE4gNheuFwsrlrSRQShuYq7sje5yrjKbbYM LFOLNCTp3qEYj49sA739fo2WnkC8WSmoLu1SHsatPbNe8NbOe1w8RZsO1oCBNAXESu4f VdmyC1u8Ux0KEB0MZA4tVZf+MGC+0whsAhv8l9fmvqfcaQgTNB86qLV9uKwzdmvM2AlO PpNTDWFyVn6OGH/Z0Oi16eszNgjJGS7zdHJtRlxPcfAugwXoLIUkZuybOQWAh0RkS4jb +EjeauDzMscvgCEnYw22Td5B+5sOJnl4ZEj7ZZn1O4XmcTWovcbGt3iFttutPG+uoN1t VBqw== 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=0f6WWeAxzGfUdnzC9RmPRbpZACVk5hgRjXIXObclnP8=; b=gEz4Tepj9TiRJBaL39SaSble4msb2nc6wtaPp14DJeZNl+AcSae6gwZ9HicvHwHBww 2HkJpJr1Y5xcLtsU5SiIfn5PIu9XA4T8Z+3xQSrwQ1VNji70E8MJpkZLr3mXrw0l8L0i W9pwwFSNg/r7XFBcXW3hzGzkMjmjn4wMV/pFqbu7PMo6cbGZjhntnw/qnrbbBkfp/JZn 1cH11a1S2vTyh4+OyMzb7zVh+rsEaF2HyV7yN2ejh3mhvCXQq2yPwtosbZAQe03AyyeC gudJL3nrhYwDQcu0VciYI63ebYrGFgOAtijkr2MHv41AmBggzlZ5HnLlu3sezj/EFLBe umSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UMSP38b4; 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 l22si4959895edq.174.2019.09.29.07.07.06; Sun, 29 Sep 2019 07:07: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; dkim=pass header.i=@kernel.org header.s=default header.b=UMSP38b4; 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 S1729358AbfI2ODx (ORCPT + 99 others); Sun, 29 Sep 2019 10:03:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:47026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730392AbfI2ODr (ORCPT ); Sun, 29 Sep 2019 10:03:47 -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 6A4B22086A; Sun, 29 Sep 2019 14:03:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569765827; bh=9K5VrEJ5Mu18MwhovO++6lF5hDTZl5gGUGSNuOZvb0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UMSP38b4q/LSOJTnZtc2mJGlxvvBiZAYxYW+LfjiGIZmbeVTwud3NAdhjOPkwhztP n4w3tGZMQDL/Zia2nEXnMR9DW1ZiefR8D3L+4HkCTMbxSfFooJ51P9gROCVWyCE5Lf h6BCZfTZmyH3JwLejjmWy3rRFR3Pc5aMpGuWWpzg= 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 5.3 09/25] HID: prodikeys: Fix general protection fault during probe Date: Sun, 29 Sep 2019 15:56:12 +0200 Message-Id: <20190929135012.543462189@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190929135006.127269625@linuxfoundation.org> References: <20190929135006.127269625@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 @@ -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);