linux-stable/sound/usb
Takashi Iwai e83fa9ce16 ALSA: usb-audio: Fix race against the error recovery URB submission
commit 9b7e5208a9 upstream.

USB MIDI driver has an error recovery mechanism to resubmit the URB in
the delayed timer handler, and this may race with the standard start /
stop operations.  Although both start and stop operations themselves
don't race with each other due to the umidi->mutex protection, but
this isn't applied to the timer handler.

For fixing this potential race, the following changes are applied:

- Since the timer handler can't use the mutex, we apply the
  umidi->disc_lock protection at each input stream URB submission;
  this also needs to change the GFP flag to GFP_ATOMIC
- Add a check of the URB refcount and skip if already submitted
- Move the timer cancel call at disconnection to the beginning of the
  procedure; this assures the in-flight timer handler is gone properly
  before killing all pending URBs

Reported-by: syzbot+0f4ecfe6a2c322c81728@syzkaller.appspotmail.com
Reported-by: syzbot+5f1d24c49c1d2c427497@syzkaller.appspotmail.com
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200710160656.16819-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-07-22 09:32:08 +02:00
..
6fire ALSA: pcm: Nuke snd_pcm_lib_mmap_vmalloc() 2018-07-18 08:24:29 +02:00
bcd2000 sound updates for 4.15-rc1 2017-11-14 18:01:46 -08:00
caiaq ALSA: pcm: Nuke snd_pcm_lib_mmap_vmalloc() 2018-07-18 08:24:29 +02:00
hiface ALSA: hiface: fix multiple memory leak bugs 2019-08-16 10:12:51 +02:00
line6 ALSA: line6: Sync the pending work cancel at disconnection 2020-07-22 09:32:08 +02:00
misc ALSA: pcm: Nuke snd_pcm_lib_mmap_vmalloc() 2018-07-18 08:24:29 +02:00
usx2y ALSA: usx2y: Fix potential NULL dereference 2020-04-29 16:31:28 +02:00
card.c ALSA: usb-audio: Rewrite registration quirk handling 2020-07-22 09:32:04 +02:00
card.h Revert "ALSA: usb-audio: Improve frames size computation" 2020-07-09 09:37:12 +02:00
clock.c ALSA: usb-audio: Add clock validity quirk for Denon MC7000/MCX8000 2020-02-19 19:51:54 +01:00
clock.h ALSA: usb-audio: Add clock validity quirk for Denon MC7000/MCX8000 2020-02-19 19:51:54 +01:00
debug.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
endpoint.c Revert "ALSA: usb-audio: Improve frames size computation" 2020-07-09 09:37:12 +02:00
endpoint.h Revert "ALSA: usb-audio: Improve frames size computation" 2020-07-09 09:37:12 +02:00
format.c ALSA: usb-audio: Filter out unsupported sample rates on Focusrite devices 2020-04-29 16:31:29 +02:00
format.h ALSA: usb: initial USB Audio Device Class 3.0 support 2018-03-21 11:46:33 +01:00
helper.c ALSA: usb-audio: correct speed checking 2016-05-08 11:42:04 +02:00
helper.h ALSA: usb-audio: More validations of descriptor units 2019-11-12 19:20:48 +01:00
Kconfig ALSA: us122l: enable compile testing 2017-05-15 11:02:14 +02:00
Makefile ALSA: usb-audio: More validations of descriptor units 2019-11-12 19:20:48 +01:00
midi.c ALSA: usb-audio: Fix race against the error recovery URB submission 2020-07-22 09:32:08 +02:00
midi.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mixer.c ALSA: usb-audio: Fix OOB access of mixer element list 2020-06-30 23:17:08 -04:00
mixer.h ALSA: usb-audio: Fix OOB access of mixer element list 2020-06-30 23:17:08 -04:00
mixer_maps.c ALSA: usb-audio: Quirks for Gigabyte TRX40 Aorus Master onboard audio 2020-06-03 08:19:39 +02:00
mixer_quirks.c ALSA: usb-audio: Fix OOB access of mixer element list 2020-06-30 23:17:08 -04:00
mixer_quirks.h ALSA: usb-audio: Initialize Dell Dock playback volumes 2018-05-02 16:02:32 +02:00
mixer_scarlett.c ALSA: usb-audio: Clean up mixer element list traverse 2018-05-03 12:35:19 +02:00
mixer_scarlett.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mixer_us16x08.c ALSA: usb: Avoid VLA in mixer_us16x08.c 2017-05-31 08:46:19 +02:00
mixer_us16x08.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pcm.c Revert "ALSA: usb-audio: Improve frames size computation" 2020-07-09 09:37:12 +02:00
pcm.h ALSA: usb-audio: Add UAC3 Power Domains to suspend/resume 2018-07-31 15:01:36 +02:00
power.c ALSA: usb-audio: More validations of descriptor units 2019-11-12 19:20:48 +01:00
power.h ALSA: usb-audio: Initial Power Domain support 2018-07-31 15:01:22 +02:00
proc.c ALSA: usb-audio: Avoid nested autoresume calls 2015-08-26 15:38:25 +02:00
proc.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
quirks-table.h ALSA: usb-audio: add quirk for MacroSilicon MS2109 2020-07-16 08:17:25 +02:00
quirks.c ALSA: usb-audio: Add registration quirk for Kingston HyperX Cloud Flight S 2020-07-22 09:32:05 +02:00
quirks.h ALSA: usb-audio: Rewrite registration quirk handling 2020-07-22 09:32:04 +02:00
stream.c ALSA: usb-audio: More validations of descriptor units 2019-11-12 19:20:48 +01:00
stream.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
usbaudio.h ALSA: usb-audio: Fix inconsistent card PM state after resume 2020-06-22 09:05:02 +02:00
validate.c ALSA: usb-audio: Fix endianess in descriptor validation 2020-02-11 04:33:56 -08:00