]> git.ipfire.org Git - people/arne_f/kernel.git/commit
ALSA: pcm: Clear the full allocated memory at hw_params
authorTakashi Iwai <tiwai@suse.de>
Fri, 18 Dec 2020 14:56:25 +0000 (15:56 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 9 Jan 2021 12:37:39 +0000 (13:37 +0100)
commit3f8c7a235a524343f2705196bba6c723b3a1fd98
tree48fc634ffd95c3cb3a308cf740903e0f5d873b7f
parentc4c670e1ea402b5657c5c4835f6669a5d39ee534
ALSA: pcm: Clear the full allocated memory at hw_params

[ Upstream commit 618de0f4ef11acd8cf26902e65493d46cc20cc89 ]

The PCM hw_params core function tries to clear up the PCM buffer
before actually using for avoiding the information leak from the
previous usages or the usage before a new allocation.  It performs the
memset() with runtime->dma_bytes, but this might still leave some
remaining bytes untouched; namely, the PCM buffer size is aligned in
page size for mmap, hence runtime->dma_bytes doesn't necessarily cover
all PCM buffer pages, and the remaining bytes are exposed via mmap.

This patch changes the memory clearance to cover the all buffer pages
if the stream is supposed to be mmap-ready (that guarantees that the
buffer size is aligned in page size).

Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20201218145625.2045-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/core/pcm_native.c