Skip to content

Commit c0a697d

Browse files
AlanSterngregkh
authored andcommitted
HID: prodikeys: Fix general protection fault during probe
commit 98375b8 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: [email protected] Signed-off-by: Alan Stern <[email protected]> CC: <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 787f774 commit c0a697d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/hid/hid-prodikeys.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,10 +556,14 @@ static void pcmidi_setup_extra_keys(
556556

557557
static int pcmidi_set_operational(struct pcmidi_snd *pm)
558558
{
559+
int rc;
560+
559561
if (pm->ifnum != 1)
560562
return 0; /* only set up ONCE for interace 1 */
561563

562-
pcmidi_get_output_report(pm);
564+
rc = pcmidi_get_output_report(pm);
565+
if (rc < 0)
566+
return rc;
563567
pcmidi_submit_output_report(pm, 0xc1);
564568
return 0;
565569
}
@@ -688,7 +692,11 @@ static int pcmidi_snd_initialise(struct pcmidi_snd *pm)
688692
spin_lock_init(&pm->rawmidi_in_lock);
689693

690694
init_sustain_timers(pm);
691-
pcmidi_set_operational(pm);
695+
err = pcmidi_set_operational(pm);
696+
if (err < 0) {
697+
pk_error("failed to find output report\n");
698+
goto fail_register;
699+
}
692700

693701
/* register it */
694702
err = snd_card_register(card);

0 commit comments

Comments
 (0)