]> git.baikalelectronics.ru Git - kernel.git/commit
ALSA: memalloc: Align buffer allocations in page size
authorTakashi Iwai <tiwai@suse.de>
Fri, 18 Dec 2020 14:56:24 +0000 (15:56 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 29 Jul 2022 15:14:18 +0000 (17:14 +0200)
commit796f5fb4496093f0d35b2c28ca5008c58a128d25
treeaa73a1f34707f52f50332c22e923c8b37cfa7968
parent40eb7fe697a0093175ce7af3e2ce8d07a0f46979
ALSA: memalloc: Align buffer allocations in page size

commit 4c548e0c0c1c272a68492d32bcebb7cb15270e88 upstream.

Currently the standard memory allocator (snd_dma_malloc_pages*())
passes the byte size to allocate as is.  Most of the backends
allocates real pages, hence the actual allocations are aligned in page
size.  However, the genalloc doesn't seem assuring the size alignment,
hence it may result in the access outside the buffer when the whole
memory pages are exposed via mmap.

For avoiding such inconsistencies, this patch makes the allocation
size always to be aligned in page size.

Note that, after this change, snd_dma_buffer.bytes field contains the
aligned size, not the originally requested size.  This value is also
used for releasing the pages in return.

Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20201218145625.2045-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/core/memalloc.c