From a02d521d946bbdfd76df52389341763e1e7c7625 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 27 Jul 2022 10:11:14 +0200 Subject: [PATCH] 4.9-stable patches added patches: alsa-memalloc-align-buffer-allocations-in-page-size.patch --- ...lign-buffer-allocations-in-page-size.patch | 41 +++++++++++++++++++ queue-4.9/series | 1 + 2 files changed, 42 insertions(+) create mode 100644 queue-4.9/alsa-memalloc-align-buffer-allocations-in-page-size.patch diff --git a/queue-4.9/alsa-memalloc-align-buffer-allocations-in-page-size.patch b/queue-4.9/alsa-memalloc-align-buffer-allocations-in-page-size.patch new file mode 100644 index 00000000000..86bf8d99262 --- /dev/null +++ b/queue-4.9/alsa-memalloc-align-buffer-allocations-in-page-size.patch @@ -0,0 +1,41 @@ +From 5c1733e33c888a3cb7f576564d8ad543d5ad4a9e Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Fri, 18 Dec 2020 15:56:24 +0100 +Subject: ALSA: memalloc: Align buffer allocations in page size + +From: Takashi Iwai + +commit 5c1733e33c888a3cb7f576564d8ad543d5ad4a9e 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 +Link: https://lore.kernel.org/r/20201218145625.2045-2-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/core/memalloc.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/sound/core/memalloc.c ++++ b/sound/core/memalloc.c +@@ -177,6 +177,7 @@ int snd_dma_alloc_pages(int type, struct + if (WARN_ON(!dmab)) + return -ENXIO; + ++ size = PAGE_ALIGN(size); + dmab->dev.type = type; + dmab->dev.dev = device; + dmab->bytes = 0; diff --git a/queue-4.9/series b/queue-4.9/series index d722ea9ed12..ae0377b4aca 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -17,3 +17,4 @@ be2net-fix-buffer-overflow-in-be_get_module_eeprom.patch revert-revert-char-random-silence-a-lockdep-splat-with-printk.patch mm-mempolicy-fix-uninit-value-in-mpol_rebind_policy.patch bpf-make-sure-mac_header-was-set-before-using-it.patch +alsa-memalloc-align-buffer-allocations-in-page-size.patch -- 2.47.3