]> git.ipfire.org Git - thirdparty/kernel/stable.git/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:07:32 +0000 (13:07 +0200)
commit4031b72ca747a1e6e9ae4fa729e765b43363d66a
tree18c121e600101a62f53e55c6215c8b7a27ae5c1d
parent9470114dfaf4798757d4ce1d81d9becb764c6fb7
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