arch/x86/kvm/svm/sev.c:672:60: sparse: sparse: dereference of noderef expression

From: kernel test robot
Date: Tue Sep 22 2020 - 21:31:15 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 805c6d3c19210c90c109107d189744e960eae025
commit: eaf78265a4ab33935d3a0f1407ce4a91aac4d4d5 KVM: SVM: Move SEV code to separate file
date: 6 months ago
config: x86_64-randconfig-s022-20200922 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.2-201-g24bdaac6-dirty
git checkout eaf78265a4ab33935d3a0f1407ce4a91aac4d4d5
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>


sparse warnings: (new ones prefixed by >>)

>> arch/x86/kvm/svm/sev.c:672:60: sparse: sparse: dereference of noderef expression
>> arch/x86/kvm/svm/sev.c:672:60: sparse: sparse: dereference of noderef expression
arch/x86/kvm/svm/sev.c:695:14: sparse: sparse: dereference of noderef expression
arch/x86/kvm/svm/sev.c:701:59: sparse: sparse: dereference of noderef expression
arch/x86/kvm/svm/sev.c:701:59: sparse: sparse: dereference of noderef expression
arch/x86/kvm/svm/sev.c:715:14: sparse: sparse: dereference of noderef expression
arch/x86/kvm/svm/sev.c:740:70: sparse: sparse: dereference of noderef expression
arch/x86/kvm/svm/sev.c:740:70: sparse: sparse: dereference of noderef expression

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eaf78265a4ab33935d3a0f1407ce4a91aac4d4d5
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout eaf78265a4ab33935d3a0f1407ce4a91aac4d4d5
vim +672 arch/x86/kvm/svm/sev.c

646
647 static int __sev_dbg_decrypt_user(struct kvm *kvm, unsigned long paddr,
648 unsigned long __user dst_uaddr,
649 unsigned long dst_paddr,
650 int size, int *err)
651 {
652 struct page *tpage = NULL;
653 int ret, offset;
654
655 /* if inputs are not 16-byte then use intermediate buffer */
656 if (!IS_ALIGNED(dst_paddr, 16) ||
657 !IS_ALIGNED(paddr, 16) ||
658 !IS_ALIGNED(size, 16)) {
659 tpage = (void *)alloc_page(GFP_KERNEL);
660 if (!tpage)
661 return -ENOMEM;
662
663 dst_paddr = __sme_page_pa(tpage);
664 }
665
666 ret = __sev_dbg_decrypt(kvm, paddr, dst_paddr, size, err);
667 if (ret)
668 goto e_free;
669
670 if (tpage) {
671 offset = paddr & 15;
> 672 if (copy_to_user((void __user *)(uintptr_t)dst_uaddr,
673 page_address(tpage) + offset, size))
674 ret = -EFAULT;
675 }
676
677 e_free:
678 if (tpage)
679 __free_page(tpage);
680
681 return ret;
682 }
683

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip