linux/sound/core
Takashi Iwai 67ec1072b0 ALSA: pcm: Fix rwsem deadlock for non-atomic PCM stream
A non-atomic PCM stream may take snd_pcm_link_rwsem rw semaphore twice
in the same code path, e.g. one in snd_pcm_action_nonatomic() and
another in snd_pcm_stream_lock().  Usually this is OK, but when a
write lock is issued between these two read locks, the problem
happens: the write lock is blocked due to the first reade lock, and
the second read lock is also blocked by the write lock.  This
eventually deadlocks.

The reason is the way rwsem manages waiters; it's queued like FIFO, so
even if the writer itself doesn't take the lock yet, it blocks all the
waiters (including reads) queued after it.

As a workaround, in this patch, we replace the standard down_write()
with an spinning loop.  This is far from optimal, but it's good
enough, as the spinning time is supposed to be relatively short for
normal PCM operations, and the code paths requiring the write lock
aren't called so often.

Reported-by: Vinod Koul <vinod.koul@intel.com>
Tested-by: Ramesh Babu <ramesh.babu@intel.com>
Cc: <stable@vger.kernel.org> # v3.18+
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-02-18 11:27:52 +01:00
..
oss ALSA: pcm: Fix potential deadlock in OSS emulation 2016-02-01 12:23:29 +01:00
seq ALSA: seq: Fix double port list deletion 2016-02-16 14:37:19 +01:00
Kconfig ALSA: timer: fix SND_PCM_TIMER Kconfig text 2016-01-28 07:23:12 +01:00
Makefile
compress_offload.c ALSA: compress: Disable GET_CODEC_CAPS ioctl for some architectures 2016-01-25 20:27:33 +01:00
control.c ALSA: control: Avoid kernel warnings from tlv ioctl with numid 0 2016-01-18 14:40:07 +01:00
control_compat.c
ctljack.c
device.c
hrtimer.c ALSA: hrtimer: Fix stall by hrtimer_cancel() 2016-01-18 14:33:30 +01:00
hwdep.c
hwdep_compat.c
info.c
info_oss.c
init.c ALSA: hda_intel: add card number to irq description 2016-01-12 21:05:16 +01:00
isadma.c
jack.c
memalloc.c
memory.c
misc.c
pcm.c
pcm_compat.c ALSA: pcm: Fix snd_pcm_hw_params struct copy in compat mode 2016-01-18 14:39:00 +01:00
pcm_dmaengine.c ALSA: pcm_dmaengine: Properly synchronize DMA on shutdown 2015-11-16 08:28:52 +05:30
pcm_drm_eld.c
pcm_iec958.c
pcm_lib.c
pcm_memory.c
pcm_misc.c
pcm_native.c ALSA: pcm: Fix rwsem deadlock for non-atomic PCM stream 2016-02-18 11:27:52 +01:00
pcm_timer.c
pcm_trace.h
rawmidi.c ALSA: rawmidi: Fix race at copying & updating the position 2016-02-03 14:51:42 +01:00
rawmidi_compat.c
rtctimer.c
sgbuf.c
sound.c
sound_oss.c
timer.c ALSA: timer: Fix race at concurrent reads 2016-02-09 12:23:42 +01:00
timer_compat.c
vmaster.c