linux-stable/kernel/dma
Robin Murphy 204dfb6305 dma-direct: don't over-decrypt memory
[ Upstream commit 4a37f3dd9a ]

The original x86 sev_alloc() only called set_memory_decrypted() on
memory returned by alloc_pages_node(), so the page order calculation
fell out of that logic. However, the common dma-direct code has several
potential allocators, not all of which are guaranteed to round up the
underlying allocation to a power-of-two size, so carrying over that
calculation for the encryption/decryption size was a mistake. Fix it by
rounding to a *number* of pages, rather than an order.

Until recently there was an even worse interaction with DMA_DIRECT_REMAP
where we could have ended up decrypting part of the next adjacent
vmalloc area, only averted by no architecture actually supporting both
configs at once. Don't ask how I found that one out...

Fixes: c10f07aa27 ("dma/direct: Handle force decryption for DMA coherent buffers in common code")
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-06-09 10:25:58 +02:00
..
Kconfig Merge branch 'stable/for-linus-5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb 2021-09-03 10:34:44 -07:00
Makefile dma-mapping updates for 5.11: 2020-12-22 13:19:43 -08:00
coherent.c dma-mapping: use 'bitmap_zalloc()' when applicable 2021-10-27 08:20:09 +02:00
contiguous.c dma-contiguous: fix a typo error in a comment 2020-11-27 10:33:42 +01:00
debug.c dma-debug: change allocation mode from GFP_NOWAIT to GFP_ATIOMIC 2022-06-09 10:25:26 +02:00
debug.h dma-debug: teach add_dma_entry() about DMA_ATTR_SKIP_CPU_SYNC 2021-10-18 12:46:45 +02:00
direct.c dma-direct: don't over-decrypt memory 2022-06-09 10:25:58 +02:00
direct.h dma-direct: avoid redundant memory sync for swiotlb 2022-04-20 09:36:27 +02:00
dummy.c dma-mapping: return error code from dma_dummy_map_sg() 2021-08-09 17:13:06 +02:00
map_benchmark.c dma-mapping: benchmark: Add support for multi-pages map/unmap 2021-04-02 16:41:08 +02:00
mapping.c arm64 updates for 5.16 2021-11-01 16:33:53 -07:00
ops_helpers.c dma-mapping: handle vmalloc addresses in dma_common_{mmap,get_sgtable} 2021-07-16 11:30:26 +02:00
pool.c dma/pool: create dma atomic pool only if dma zone has managed pages 2022-01-15 16:30:29 +02:00
remap.c kernel/dma: remove unnecessary unmap_kernel_range 2021-04-30 11:20:40 -07:00
swiotlb.c Reinstate some of "swiotlb: rework "fix info leak with DMA_FROM_DEVICE"" 2022-04-08 13:58:59 +02:00