Patch "crypto: ccp: Detect and reject "invalid" addresses destined for PSP" has been added to the 5.10-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

    crypto: ccp: Detect and reject "invalid" addresses destined for PSP

to the 5.10-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:
     crypto-ccp-detect-and-reject-invalid-addresses-desti.patch
and it can be found in the queue-5.10 subdirectory.

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



commit afbaa9a17e553951892bbcea25a61f18b86dab8e
Author: Sean Christopherson <seanjc@xxxxxxxxxx>
Date:   Tue Apr 6 15:49:46 2021 -0700

    crypto: ccp: Detect and reject "invalid" addresses destined for PSP
    
    [ Upstream commit 74c1f1366eb7714b8b211554f6c5cee315ff3fbc ]
    
    Explicitly reject using pointers that are not virt_to_phys() friendly
    as the source for SEV commands that are sent to the PSP.  The PSP works
    with physical addresses, and __pa()/virt_to_phys() will not return the
    correct address in these cases, e.g. for a vmalloc'd pointer.  At best,
    the bogus address will cause the command to fail, and at worst lead to
    system instability.
    
    While it's unlikely that callers will deliberately use a bad pointer for
    SEV buffers, a caller can easily use a vmalloc'd pointer unknowingly when
    running with CONFIG_VMAP_STACK=y as it's not obvious that putting the
    command buffers on the stack would be bad.  The command buffers are
    relative  small and easily fit on the stack, and the APIs to do not
    document that the incoming pointer must be a physically contiguous,
    __pa() friendly pointer.
    
    Cc: Brijesh Singh <brijesh.singh@xxxxxxx>
    Cc: Borislav Petkov <bp@xxxxxxx>
    Cc: Tom Lendacky <thomas.lendacky@xxxxxxx>
    Cc: Christophe Leroy <christophe.leroy@xxxxxxxxxx>
    Fixes: 200664d5237f ("crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support")
    Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
    Message-Id: <20210406224952.4177376-3-seanjc@xxxxxxxxxx>
    Reviewed-by: Brijesh Singh <brijesh.singh@xxxxxxx>
    Acked-by: Tom Lendacky <thomas.lendacky@xxxxxxx>
    Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 476113e12489..5b82ba7acc7c 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -149,6 +149,9 @@ static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret)
 
 	sev = psp->sev_data;
 
+	if (data && WARN_ON_ONCE(!virt_addr_valid(data)))
+		return -EINVAL;
+
 	/* Get the physical address of the command buffer */
 	phys_lsb = data ? lower_32_bits(__psp_pa(data)) : 0;
 	phys_msb = data ? upper_32_bits(__psp_pa(data)) : 0;



[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