linux-stable/sound/core
Takashi Iwai f5c00f4433 ALSA: usb-audio: Fix recursive locking at XRUN during syncing
[ Upstream commit 8c721c53dd ]

The recent support of low latency playback in USB-audio driver made
the snd_usb_queue_pending_output_urbs() function to be called via PCM
ack ops.  In the new code path, the function is performed already in
the PCM stream lock.  The problem is that, when an XRUN is detected,
the function calls snd_pcm_xrun() to notify, but snd_pcm_xrun() is
supposed to be called only outside the stream lock.  As a result, it
leads to a deadlock of PCM stream locking.

For avoiding such a recursive locking, this patch adds an additional
check to the code paths in PCM core that call the ack callback; now it
checks the error code from the callback, and if it's -EPIPE, the XRUN
is handled in the PCM core side gracefully.  Along with it, the
USB-audio driver code is changed to follow that, i.e. -EPIPE is
returned instead of the explicit snd_pcm_xrun() call when the function
is performed already in the stream lock.

Fixes: d5f871f89e ("ALSA: usb-audio: Improved lowlatency playback support")
Reported-and-tested-by: John Keeping <john@metanate.com>
Link: https://lore.kernel.org/r/20230317195128.3911155-1-john@metanate.com
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Reviewed-by; Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20230320142838.494-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-04-06 12:12:31 +02:00
..
oss ALSA: pcm: Avoid reference to status->state 2022-09-27 08:44:05 +02:00
seq ALSA: seq: Fix function prototype mismatch in snd_seq_expand_var_event 2022-11-19 09:20:11 +01:00
Kconfig ALSA: control: Add input validation 2022-06-15 07:45:28 +02:00
Makefile m68k: coldfire: drop ISA_DMA_API support 2022-05-16 13:18:30 +10:00
compress_offload.c ALSA: compress: Fix kernel doc warnings 2022-07-13 13:42:36 +02:00
control.c ALSA: pcm: Move rwsem lock inside snd_ctl_elem_read to prevent UAF 2023-01-13 14:15:26 +01:00
control_compat.c
control_led.c ALSA: control-led: use strscpy in set_led_id() 2023-01-09 17:03:24 +01:00
ctljack.c
device.c ALSA: core: Fix missing return value comments for kernel docs 2022-07-13 13:42:38 +02:00
hrtimer.c
hwdep.c
hwdep_compat.c
info.c ALSA: info: Fix llseek return value when using callback 2022-08-17 15:13:30 +02:00
info_oss.c
init.c ALSA: core: Fix double-free at snd_card_new() 2022-09-19 14:36:06 +02:00
isadma.c sound updates for 6.0-rc1 2022-08-06 10:19:51 -07:00
jack.c
memalloc.c ALSA: memalloc: Workaround for Xen PV 2023-01-27 09:16:24 +01:00
memalloc_local.h ALSA: memalloc: remove snd_dma_sg_ops declaration 2022-09-09 09:09:40 +02:00
memory.c
misc.c ALSA: core: Add async signal helpers 2022-07-29 12:57:10 +02:00
pcm.c ALSA: pcm: Avoid reference to status->state 2022-09-27 08:44:05 +02:00
pcm_compat.c ALSA: pcm: Avoid reference to status->state 2022-09-27 08:44:05 +02:00
pcm_dmaengine.c ALSA: dmaengine: increment buffer pointer atomically 2022-09-27 08:55:05 +02:00
pcm_drm_eld.c
pcm_iec958.c
pcm_lib.c ALSA: usb-audio: Fix recursive locking at XRUN during syncing 2023-04-06 12:12:31 +02:00
pcm_local.h
pcm_memory.c ALSA: pcm: Fix missing return value comments for kernel docs 2022-07-13 13:42:34 +02:00
pcm_misc.c
pcm_native.c ALSA: pcm: Handle XRUN at trigger START 2022-12-05 14:22:48 +01:00
pcm_param_trace.h
pcm_timer.c
pcm_trace.h ALSA: pcm: fix tracing reason in hw_ptr_error 2022-11-28 14:55:41 +01:00
rawmidi.c ALSA: rawmidi: remove variable dest_frames 2022-10-24 16:01:05 +02:00
rawmidi_compat.c
seq_device.c
sound.c
sound_oss.c ALSA: oss: Fix potential deadlock at unregistration 2022-10-11 09:02:43 +02:00
timer.c ALSA: timer: Use deferred fasync helper 2022-07-29 12:57:11 +02:00
timer_compat.c
vmaster.c ALSA: core: Fix missing return value comments for kernel docs 2022-07-13 13:42:38 +02:00