linux-stable/sound
Takashi Iwai 87988a534d ALSA: Fix deadlocks with kctl removals at disconnection
In snd_card_disconnect(), we set card->shutdown flag at the beginning,
call callbacks and do sync for card->power_ref_sleep waiters at the
end.  The callback may delete a kctl element, and this can lead to a
deadlock when the device was in the suspended state.  Namely:

* A process waits for the power up at snd_power_ref_and_wait() in
  snd_ctl_info() or read/write() inside card->controls_rwsem.

* The system gets disconnected meanwhile, and the driver tries to
  delete a kctl via snd_ctl_remove*(); it tries to take
  card->controls_rwsem again, but this is already locked by the
  above.  Since the sleeper isn't woken up, this deadlocks.

An easy fix is to wake up sleepers before processing the driver
disconnect callbacks but right after setting the card->shutdown flag.
Then all sleepers will abort immediately, and the code flows again.

So, basically this patch moves the wait_event() call at the right
timing.  While we're at it, just to be sure, call wait_event_all()
instead of wait_event(), although we don't use exclusive events on
this queue for now.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=218816
Cc: <stable@vger.kernel.org>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20240510101424.6279-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-05-10 14:49:32 +02:00
..
ac97 ALSA: ac97: fix build regression 2024-01-03 11:47:04 +01:00
aoa ASoC: Fixes for v6.9 2024-04-05 08:48:12 +02:00
arm ALSA: aaci: Delete unused variable in aaci_do_suspend 2024-03-12 12:30:51 +01:00
atmel
core ALSA: Fix deadlocks with kctl removals at disconnection 2024-05-10 14:49:32 +02:00
drivers TTY/Serial driver update for 6.9-rc1 2024-03-21 12:44:10 -07:00
firewire Merge branch 'for-linus' into for-next 2024-02-21 11:17:06 +01:00
hda ALSA: hda: intel-sdw-acpi: fix usage of device_get_named_child_node() 2024-04-29 17:32:27 +02:00
i2c
isa ALSA: wavefront: copy userspace array safely 2023-11-20 12:38:31 +01:00
mips
oss OSS: dmasound/paula: Mark driver struct with __refdata to prevent section mismatch 2024-04-01 13:47:09 +02:00
parisc
pci ALSA: hda/realtek: Fix build error without CONFIG_PM 2024-05-02 08:25:06 +02:00
pcmcia
ppc
sh ALSA: sh: aica: reorder cleanup operations to avoid UAF bugs 2024-03-26 12:18:54 +01:00
soc ASoC: mediatek: mt8192: fix register configuration for tdm 2024-05-09 17:43:54 +02:00
sparc
spi ALSA: at73c213: Replace with DEFINE_SIMPLE_DEV_PM_OPS() 2024-02-12 11:50:25 +01:00
synth ALSA: synth: Save a few bytes of memory when registering a 'snd_emux' 2024-01-22 13:04:22 +01:00
usb ALSA: line6: Zero-initialize message buffers 2024-04-02 15:01:27 +02:00
virtio ALSA: virtio: Fix "Coverity: virtsnd_kctl_tlv_op(): Uninitialized variables" warning. 2024-02-16 15:01:31 +01:00
x86 drm/edid: include drm_eld.h only where required 2023-11-09 16:47:31 +02:00
xen ALSA: xen: Fix -Wformat-truncation warning 2023-09-15 13:21:35 +02:00
ac97_bus.c ALSA: mark all struct bus_type as const 2023-12-30 10:10:41 +01:00
Kconfig
last.c
Makefile
sound_core.c