All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Alan Stern <stern@rowland.harvard.edu>,
	Jiri Kosina <jkosina@suse.cz>,
	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	[thread overview]
Message-ID: <20190929135012.543462189@linuxfoundation.org> (raw)
In-Reply-To: <20190929135006.127269625@linuxfoundation.org>

From: Alan Stern <stern@rowland.harvard.edu>

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 <stern@rowland.harvard.edu>
CC: <stable@vger.kernel.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 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);



  parent reply	other threads:[~2019-09-29 14:03 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-29 13:56 [PATCH 5.3 00/25] 5.3.2-stable review Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 01/25] netfilter: add missing IS_ENABLED(CONFIG_NF_TABLES) check to header-file Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 02/25] clocksource/drivers/timer-of: Do not warn on deferred probe Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 03/25] clocksource/drivers: Do not warn on probe defer Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 04/25] drm/amd/display: Allow cursor async updates for framebuffer swaps Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 05/25] drm/amd/display: Skip determining update type for async updates Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 06/25] drm/amd/display: Dont replace the dc_state for fast updates Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 07/25] drm/amd/display: readd -msse2 to prevent Clang from emitting libcalls to undefined SW FP routines Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 08/25] powerpc/xive: Fix bogus error code returned by OPAL Greg Kroah-Hartman
2019-09-29 13:56 ` Greg Kroah-Hartman [this message]
2019-09-29 13:56 ` [PATCH 5.3 10/25] HID: sony: Fix memory corruption issue on cleanup Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 11/25] HID: logitech: Fix general protection fault caused by Logitech driver Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 12/25] HID: logitech-dj: Fix crash when initial logi_dj_recv_query_paired_devices fails Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 13/25] HID: hidraw: Fix invalid read in hidraw_ioctl Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 14/25] HID: Add quirk for HP X500 PIXART OEM mouse Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 15/25] mtd: cfi_cmdset_0002: Use chip_good() to retry in do_write_oneword() Greg Kroah-Hartman
2019-09-29 13:56   ` Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 16/25] crypto: talitos - fix missing break in switch statement Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 17/25] clk: imx: imx8mm: fix audio pll setting Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 18/25] Revert "mm/z3fold.c: fix race between migration and destruction" Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 19/25] ALSA: usb-audio: Add Hiby device family to quirks for native DSD support Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 20/25] ALSA: usb-audio: Add DSD support for EVGA NU Audio Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 21/25] ALSA: dice: fix wrong packet parameter for Alesis iO26 Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 22/25] ALSA: hda - Add laptop imic fixup for ASUS M9V laptop Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 23/25] ALSA: hda - Apply AMD controller workaround for Raven platform Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 24/25] platform/x86: i2c-multi-instantiate: Derive the device name from parent Greg Kroah-Hartman
2019-09-29 13:56 ` [PATCH 5.3 25/25] objtool: Clobber user CFLAGS variable Greg Kroah-Hartman
2019-09-30 18:30 ` [PATCH 5.3 00/25] 5.3.2-stable review Guenter Roeck
2019-10-01  6:19   ` Greg Kroah-Hartman
2019-09-30 22:31 ` shuah
2019-10-01  6:18   ` Greg Kroah-Hartman
2019-10-01  1:11 ` Dan Rue
2019-10-01  6:18   ` Greg Kroah-Hartman
2019-10-01 14:59 ` Jon Hunter
2019-10-01 16:59   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190929135012.543462189@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=syzbot+1088533649dafa1c9004@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.