linux-stable/sound/core
Clement Lecigne df02234e6b ALSA: pcm: Move rwsem lock inside snd_ctl_elem_read to prevent UAF
[ Note: this is a fix that works around the bug equivalently as the
  two upstream commits:
   1fa4445f9a ("ALSA: control - introduce snd_ctl_notify_one() helper")
   56b88b5056 ("ALSA: pcm: Move rwsem lock inside snd_ctl_elem_read to prevent UAF")
  but in a simpler way to fit with older stable trees -- tiwai ]

Add missing locking in ctl_elem_read_user/ctl_elem_write_user which can be
easily triggered and turned into an use-after-free.

Example code paths with SNDRV_CTL_IOCTL_ELEM_READ:

64-bits:
snd_ctl_ioctl
  snd_ctl_elem_read_user
    [takes controls_rwsem]
    snd_ctl_elem_read [lock properly held, all good]
    [drops controls_rwsem]

32-bits (compat):
snd_ctl_ioctl_compat
  snd_ctl_elem_write_read_compat
    ctl_elem_write_read
      snd_ctl_elem_read [missing lock, not good]

CVE-2023-0266 was assigned for this issue.

Signed-off-by: Clement Lecigne <clecigne@google.com>
Cc: stable@kernel.org # 5.12 and older
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-01-14 10:16:52 +01:00
..
oss ALSA: pcm: oss: Fix race at SNDCTL_DSP_SYNC 2022-10-15 07:55:51 +02:00
seq ALSA: seq: Fix function prototype mismatch in snd_seq_expand_var_event 2022-12-14 11:31:53 +01:00
compress_offload.c ALSA: compress_offload: remove redundant initialization 2020-09-03 09:26:27 +02:00
control.c ALSA: control: Use deferred fasync helper 2022-08-25 11:38:21 +02:00
control_compat.c ALSA: pcm: Move rwsem lock inside snd_ctl_elem_read to prevent UAF 2023-01-14 10:16:52 +01:00
ctljack.c
device.c ALSA: core: Add snd_device_get_state() helper 2020-03-23 18:09:19 +01:00
hrtimer.c ALSA: timer: Replace tasklet with work 2020-09-09 18:32:52 +02:00
hwdep.c ALSA: compat_ioctl: avoid compat_alloc_user_space 2020-09-21 10:37:07 +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:37:49 +02:00
info_oss.c
init.c ALSA: core: remove redundant spin_lock pair in snd_card_disconnect 2021-05-14 09:50:31 +02:00
isadma.c
jack.c ALSA: jack: Access input_dev under mutex 2022-06-09 10:20:51 +02:00
Kconfig ALSA: control: Add verification for kctl accesses 2020-01-04 09:37:59 +01:00
Makefile ALSA: ISA: not for M68K 2021-11-26 10:39:10 +01:00
memalloc.c ALSA: memalloc: Align buffer allocations in page size 2022-07-29 17:19:25 +02:00
memory.c
misc.c ALSA: core: Add async signal helpers 2022-08-25 11:38:20 +02:00
pcm.c ALSA: pcm: Fix potential AB/BA lock with buffer_mutex and mmap_lock 2022-04-08 14:39:53 +02:00
pcm_compat.c ALSA: pcm: Workaround for a wrong offset in SYNC_PTR compat ioctl 2021-10-20 11:44:57 +02:00
pcm_dmaengine.c ALSA: dmaengine: increment buffer pointer atomically 2022-10-26 13:25:27 +02:00
pcm_drm_eld.c
pcm_iec958.c ALSA: core: pcm_iec958: fix kernel-doc 2020-07-07 10:22:33 +02:00
pcm_lib.c ALSA: pcm: Fix potential AB/BA lock with buffer_mutex and mmap_lock 2022-04-08 14:39:53 +02:00
pcm_local.h ALSA: pcm: Call sync_stop at disconnection 2021-03-04 11:37:19 +01:00
pcm_memory.c ALSA: pcm: Check for null pointer of pointer substream before dereferencing it 2022-06-09 10:21:03 +02:00
pcm_misc.c ALSA: pcm: Test for "silence" field in struct "pcm_format_data" 2022-04-20 09:23:27 +02:00
pcm_native.c ALSA: pcm: Set missing stop_operating flag at undoing trigger start 2023-01-14 10:15:38 +01:00
pcm_param_trace.h
pcm_timer.c ALSA: timer: Constify snd_timer_hardware definitions 2020-01-03 09:24:07 +01:00
pcm_trace.h
rawmidi.c ALSA: rawmidi: Drop register_mutex in snd_rawmidi_free() 2022-10-26 13:25:06 +02:00
rawmidi_compat.c
seq_device.c ALSA: seq: Fix a potential UAF by wrong private_free call order 2021-10-20 11:44:57 +02:00
sgbuf.c ALSA: memalloc: Make SG-buffer helper usable for continuous buffer, too 2020-06-15 18:01:52 +02:00
sound.c
sound_oss.c ALSA: oss: Fix potential deadlock at unregistration 2022-10-26 13:25:06 +02:00
timer.c ALSA: timer: Use deferred fasync helper 2022-08-25 11:38:20 +02:00
timer_compat.c ALSA: Avoid using timespec for struct snd_timer_tread 2019-12-13 11:25:57 +01:00
vmaster.c ALSA: Replace the word "slave" in vmaster API 2020-07-20 10:10:47 +02:00