linux-stable/sound/core
Takashi Iwai cb1baad60e 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-05 11:24:54 +02:00
..
oss ALSA: pcm: oss: Fix race at SNDCTL_DSP_SYNC 2022-09-15 11:30:02 +02:00
seq ALSA: seq: Fix function prototype mismatch in snd_seq_expand_var_event 2022-12-14 11:37:16 +01:00
compress_offload.c ALSA: compress: Initialize mutex in snd_compress_new() 2021-07-15 10:22:38 +02:00
control.c ALSA: pcm: Move rwsem lock inside snd_ctl_elem_read to prevent UAF 2023-01-14 10:23:28 +01:00
control_compat.c ALSA: ctl: Fix copy of updated id with element read/write 2021-12-14 10:57:11 +01:00
control_led.c ALSA: control-led: use strscpy in set_led_id() 2023-01-18 11:48:46 +01:00
ctljack.c ALSA: Convert strlcpy to strscpy when return value is unused 2021-01-08 09:30:05 +01:00
device.c
hrtimer.c ALSA: timer: Replace tasklet with work 2020-09-09 18:32:52 +02:00
hwdep.c ALSA: core: Fix assignment in if condition 2021-06-09 17:30:22 +02:00
hwdep_compat.c ALSA: compat_ioctl: avoid compat_alloc_user_space 2020-09-21 10:37:07 +02:00
info.c ALSA: info: Fix llseek return value when using callback 2022-08-25 11:39:53 +02:00
info_oss.c ALSA: core: Fix assignment in if condition 2021-06-09 17:30:22 +02:00
init.c ALSA: core: Fix double-free at snd_card_new() 2022-09-28 11:11:40 +02:00
isadma.c ALSA: core: Add device-managed request_dma() 2021-07-19 16:16:34 +02:00
jack.c ALSA: jack: Access input_dev under mutex 2022-06-09 10:22:32 +02:00
Kconfig ALSA: control - add generic LED trigger module as the new control layer 2021-03-30 15:33:58 +02:00
Makefile ALSA: ISA: not for M68K 2021-11-25 09:48:28 +01:00
memalloc.c ALSA: memalloc: Catch call with NULL snd_dma_buffer pointer 2021-11-18 19:17:08 +01:00
memalloc_local.h ALSA: memalloc: Minor refactoring 2021-08-04 08:07:46 +02:00
memory.c
misc.c ALSA: core: Add async signal helpers 2022-08-25 11:40:44 +02:00
pcm.c ALSA: pcm: Fix potential AB/BA lock with buffer_mutex and mmap_lock 2022-04-08 14:22:55 +02:00
pcm_compat.c ALSA: pcm: Workaround for a wrong offset in SYNC_PTR compat ioctl 2021-10-11 18:10:47 +02:00
pcm_dmaengine.c ALSA: dmaengine: increment buffer pointer atomically 2022-10-26 12:34:56 +02:00
pcm_drm_eld.c
pcm_iec958.c ALSA: iec958: Split status creation and fill 2021-06-08 17:05:41 +02:00
pcm_lib.c ALSA: usb-audio: Fix recursive locking at XRUN during syncing 2023-04-05 11:24:54 +02:00
pcm_local.h ALSA: core: Abstract memory alloc helpers 2021-06-10 10:15:21 +02:00
pcm_memory.c ALSA: pcm: Check for null pointer of pointer substream before dereferencing it 2022-06-09 10:22:49 +02:00
pcm_misc.c ALSA: pcm: Test for "silence" field in struct "pcm_format_data" 2022-04-20 09:34:19 +02:00
pcm_native.c ALSA: pcm: Set missing stop_operating flag at undoing trigger start 2022-12-31 13:14:16 +01:00
pcm_param_trace.h
pcm_timer.c
pcm_trace.h
rawmidi.c ALSA: rawmidi: Drop register_mutex in snd_rawmidi_free() 2022-10-26 12:34:17 +02:00
rawmidi_compat.c ALSA: rawmidi: Add framing mode 2021-05-17 16:02:44 +02:00
seq_device.c ALSA: seq: Fix a potential UAF by wrong private_free call order 2021-09-30 14:13:22 +02:00
sgbuf.c ALSA: memalloc: Fix mmap of SG-buffer with WC pages 2021-08-08 10:01:33 +02:00
sound.c ALSA: core: Fix assignment in if condition 2021-06-09 17:30:22 +02:00
sound_oss.c ALSA: oss: Fix potential deadlock at unregistration 2022-10-26 12:34:17 +02:00
timer.c ALSA: timer: Use deferred fasync helper 2022-08-25 11:40:44 +02:00
timer_compat.c ALSA: Convert strlcpy to strscpy when return value is unused 2021-01-08 09:30:05 +01:00
vmaster.c ALSA: Replace the word "slave" in vmaster API 2020-07-20 10:10:47 +02:00