summaryrefslogtreecommitdiff
path: root/include/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2022-03-22 18:07:17 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-03-28 09:57:09 +0200
commit0f6947f5f5208f6ebd4d76a82a4757e2839a23f8 (patch)
tree518497c4a740b353d9239949df1c2eef338d69ce /include/sound
parent014c81dfb31929396c31c8b976030b56a8dc57d6 (diff)
downloadlinux-0f6947f5f5208f6ebd4d76a82a4757e2839a23f8.tar.gz
linux-0f6947f5f5208f6ebd4d76a82a4757e2839a23f8.tar.bz2
linux-0f6947f5f5208f6ebd4d76a82a4757e2839a23f8.zip
ALSA: pcm: Fix races among concurrent hw_params and hw_free calls
commit 92ee3c60ec9fe64404dc035e7c41277d74aa26cb upstream. Currently we have neither proper check nor protection against the concurrent calls of PCM hw_params and hw_free ioctls, which may result in a UAF. Since the existing PCM stream lock can't be used for protecting the whole ioctl operations, we need a new mutex to protect those racy calls. This patch introduced a new mutex, runtime->buffer_mutex, and applies it to both hw_params and hw_free ioctl code paths. Along with it, the both functions are slightly modified (the mmap_count check is moved into the state-check block) for code simplicity. Reported-by: Hu Jiahui <kirin.say@gmail.com> Cc: <stable@vger.kernel.org> Reviewed-by: Jaroslav Kysela <perex@perex.cz> Link: https://lore.kernel.org/r/20220322170720.3529-2-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/sound')
-rw-r--r--include/sound/pcm.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 2336bf9243e1..ab966563e852 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -398,6 +398,7 @@ struct snd_pcm_runtime {
wait_queue_head_t tsleep; /* transfer sleep */
struct fasync_struct *fasync;
bool stop_operating; /* sync_stop will be called */
+ struct mutex buffer_mutex; /* protect for buffer changes */
/* -- private section -- */
void *private_data;