Patch "dma-direct: re-encrypt memory if dma_direct_alloc_pages() fails" has been added to the 5.7-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    dma-direct: re-encrypt memory if dma_direct_alloc_pages() fails

to the 5.7-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     dma-direct-re-encrypt-memory-if-dma_direct_alloc_pag.patch
and it can be found in the queue-5.7 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit c4ae86f6b086f8c778709bb08a80fbd82ae8f0d0
Author: David Rientjes <rientjes@xxxxxxxxxx>
Date:   Thu Jun 11 12:20:29 2020 -0700

    dma-direct: re-encrypt memory if dma_direct_alloc_pages() fails
    
    [ Upstream commit 96a539fa3bb71f443ae08e57b9f63d6e5bb2207c ]
    
    If arch_dma_set_uncached() fails after memory has been decrypted, it needs
    to be re-encrypted before freeing.
    
    Fixes: fa7e2247c572 ("dma-direct: make uncached_kernel_address more general")
    Signed-off-by: David Rientjes <rientjes@xxxxxxxxxx>
    Signed-off-by: Christoph Hellwig <hch@xxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 8f4bbdaf965eb..4e789c46ff0bf 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -186,7 +186,7 @@ void *dma_direct_alloc_pages(struct device *dev, size_t size,
 		arch_dma_prep_coherent(page, size);
 		ret = arch_dma_set_uncached(ret, size);
 		if (IS_ERR(ret))
-			goto out_free_pages;
+			goto out_encrypt_pages;
 	}
 done:
 	if (force_dma_unencrypted(dev))
@@ -194,6 +194,11 @@ void *dma_direct_alloc_pages(struct device *dev, size_t size,
 	else
 		*dma_handle = phys_to_dma(dev, page_to_phys(page));
 	return ret;
+
+out_encrypt_pages:
+	if (force_dma_unencrypted(dev))
+		set_memory_encrypted((unsigned long)page_address(page),
+				     1 << get_order(size));
 out_free_pages:
 	dma_free_contiguous(dev, page, size);
 	return NULL;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux