On Fri, Jun 17, 2022 at 01:46:49PM +0100, Robin Murphy wrote:
[ Upstream commit 4a37f3dd9a83186cb88d44808ab35b78375082c9 ]
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: c10f07aa27da ("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 [ backport the functional change without all the prior refactoring ] Signed-off-by: Robin Murphy robin.murphy@arm.com
Hi Greg, Sasha,
I see you managed to resolve this back as far as 5.15 already, so please consider this backport to complete the set. This may need to end up in the Android 5.10 kernel in future for unpleasant reasons, but as an upstream fix I figure it may as well take the upstream stable route too.
Now queued up, thanks.
greg k-h