Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: ccp - Fix sparse warnings in sev-dev

This patch fixes a bunch of sparse warnings in sev-dev where the
__user marking is incorrectly handled.

Reported-by: kbuild test robot <lkp@intel.com>
Fixes: 7360e4b14350 ("crypto: ccp: Implement SEV_PEK_CERT_IMPORT...")
Fixes: e799035609e1 ("crypto: ccp: Implement SEV_PEK_CSR ioctl...")
Fixes: 76a2b524a4b1 ("crypto: ccp: Implement SEV_PDH_CERT_EXPORT...")
Fixes: d6112ea0cb34 ("crypto: ccp - introduce SEV_GET_ID2 command")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+17 -8
+16 -7
drivers/crypto/ccp/sev-dev.c
··· 376 376 struct sev_device *sev = psp_master->sev_data; 377 377 struct sev_user_data_pek_csr input; 378 378 struct sev_data_pek_csr *data; 379 + void __user *input_address; 379 380 void *blob = NULL; 380 381 int ret; 381 382 ··· 395 394 goto cmd; 396 395 397 396 /* allocate a physically contiguous buffer to store the CSR blob */ 397 + input_address = (void __user *)input.address; 398 398 if (input.length > SEV_FW_BLOB_MAX_SIZE) { 399 399 ret = -EFAULT; 400 400 goto e_free; ··· 428 426 } 429 427 430 428 if (blob) { 431 - if (copy_to_user((void __user *)input.address, blob, input.length)) 429 + if (copy_to_user(input_address, blob, input.length)) 432 430 ret = -EFAULT; 433 431 } 434 432 ··· 439 437 return ret; 440 438 } 441 439 442 - void *psp_copy_user_blob(u64 __user uaddr, u32 len) 440 + void *psp_copy_user_blob(u64 uaddr, u32 len) 443 441 { 444 442 if (!uaddr || !len) 445 443 return ERR_PTR(-EINVAL); ··· 448 446 if (len > SEV_FW_BLOB_MAX_SIZE) 449 447 return ERR_PTR(-EINVAL); 450 448 451 - return memdup_user((void __user *)(uintptr_t)uaddr, len); 449 + return memdup_user((void __user *)uaddr, len); 452 450 } 453 451 EXPORT_SYMBOL_GPL(psp_copy_user_blob); 454 452 ··· 623 621 { 624 622 struct sev_user_data_get_id2 input; 625 623 struct sev_data_get_id *data; 624 + void __user *input_address; 626 625 void *id_blob = NULL; 627 626 int ret; 628 627 ··· 633 630 634 631 if (copy_from_user(&input, (void __user *)argp->data, sizeof(input))) 635 632 return -EFAULT; 633 + 634 + input_address = (void __user *)input.address; 636 635 637 636 data = kzalloc(sizeof(*data), GFP_KERNEL); 638 637 if (!data) ··· 665 660 } 666 661 667 662 if (id_blob) { 668 - if (copy_to_user((void __user *)input.address, 669 - id_blob, data->len)) { 663 + if (copy_to_user(input_address, id_blob, data->len)) { 670 664 ret = -EFAULT; 671 665 goto e_free; 672 666 } ··· 724 720 struct sev_user_data_pdh_cert_export input; 725 721 void *pdh_blob = NULL, *cert_blob = NULL; 726 722 struct sev_data_pdh_cert_export *data; 723 + void __user *input_cert_chain_address; 724 + void __user *input_pdh_cert_address; 727 725 int ret; 728 726 729 727 /* If platform is not in INIT state then transition it to INIT. */ ··· 750 744 !input.pdh_cert_len || 751 745 !input.cert_chain_address) 752 746 goto cmd; 747 + 748 + input_pdh_cert_address = (void __user *)input.pdh_cert_address; 749 + input_cert_chain_address = (void __user *)input.cert_chain_address; 753 750 754 751 /* Allocate a physically contiguous buffer to store the PDH blob. */ 755 752 if (input.pdh_cert_len > SEV_FW_BLOB_MAX_SIZE) { ··· 797 788 } 798 789 799 790 if (pdh_blob) { 800 - if (copy_to_user((void __user *)input.pdh_cert_address, 791 + if (copy_to_user(input_pdh_cert_address, 801 792 pdh_blob, input.pdh_cert_len)) { 802 793 ret = -EFAULT; 803 794 goto e_free_cert; ··· 805 796 } 806 797 807 798 if (cert_blob) { 808 - if (copy_to_user((void __user *)input.cert_chain_address, 799 + if (copy_to_user(input_cert_chain_address, 809 800 cert_blob, input.cert_chain_len)) 810 801 ret = -EFAULT; 811 802 }
+1 -1
include/linux/psp-sev.h
··· 597 597 */ 598 598 int sev_guest_decommission(struct sev_data_decommission *data, int *error); 599 599 600 - void *psp_copy_user_blob(u64 __user uaddr, u32 len); 600 + void *psp_copy_user_blob(u64 uaddr, u32 len); 601 601 602 602 #else /* !CONFIG_CRYPTO_DEV_SP_PSP */ 603 603