ALSA: pcm: Fix races among concurrent prealloc proc writes
authorTakashi Iwai <tiwai@suse.de>
Fri, 6 May 2022 09:10:12 +0000 (12:10 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 May 2022 10:23:49 +0000 (12:23 +0200)
commit37b12c16beb6f6c1c3c678c1aacbc46525c250f7
tree09e7f3862c66fb90b038946a071e5ba956466320
parent2a559eec81acf4836d190d32b1e965d0c587c7ae
ALSA: pcm: Fix races among concurrent prealloc proc writes

commit 69534c48ba8ce552ce383b3dfdb271ffe51820c3 upstream.

We have no protection against concurrent PCM buffer preallocation
changes via proc files, and it may potentially lead to UAF or some
weird problem.  This patch applies the PCM open_mutex to the proc
write operation for avoiding the racy proc writes and the PCM stream
open (and further operations).

Cc: <stable@vger.kernel.org>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20220322170720.3529-5-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
[OP: backport to 5.4: adjusted context]
Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/core/pcm_memory.c