]> git.itanic.dy.fi Git - linux-stable/commit
dma-direct: Leak pages on dma_set_decrypted() failure
authorRick Edgecombe <rick.p.edgecombe@intel.com>
Thu, 22 Feb 2024 00:17:21 +0000 (16:17 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 13 Apr 2024 11:10:01 +0000 (13:10 +0200)
commitb57326c96b7bc7638aa8c44e12afa2defe0c934c
treecfc792dac4ae12bec5cf6745fe28f9bf70135dbb
parent0f53675df62b56a1e0fddab636a767a0f7a6e9d0
dma-direct: Leak pages on dma_set_decrypted() failure

[ Upstream commit b9fa16949d18e06bdf728a560f5c8af56d2bdcaf ]

On TDX it is possible for the untrusted host to cause
set_memory_encrypted() or set_memory_decrypted() to fail such that an
error is returned and the resulting memory is shared. Callers need to
take care to handle these errors to avoid returning decrypted (shared)
memory to the page allocator, which could lead to functional or security
issues.

DMA could free decrypted/shared pages if dma_set_decrypted() fails. This
should be a rare case. Just leak the pages in this case instead of
freeing them.

Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/dma/direct.c