Re: [bug report] x86/sgx: Add SGX_IOC_ENCLAVE_ADD_PAGES

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

 



On Wed, Dec 02, 2020 at 05:14:26PM +0300, Dan Carpenter wrote:
> Hello Jarkko Sakkinen,
> 
> The patch c6d26d370767: "x86/sgx: Add SGX_IOC_ENCLAVE_ADD_PAGES" from
> Nov 13, 2020, leads to the following static checker warning:
> 
> 	arch/x86/kernel/cpu/sgx/ioctl.c:466 sgx_ioc_enclave_add_pages()
> 	error: uninitialized symbol 'ret'.
> 
> arch/x86/kernel/cpu/sgx/ioctl.c
>    413  static long sgx_ioc_enclave_add_pages(struct sgx_encl *encl, void __user *arg)
>    414  {
>    415          struct sgx_enclave_add_pages add_arg;
>    416          struct sgx_secinfo secinfo;
>    417          unsigned long c;
>    418          int ret;
>    419  
>    420          if (!test_bit(SGX_ENCL_CREATED, &encl->flags) ||
>    421              test_bit(SGX_ENCL_INITIALIZED, &encl->flags))
>    422                  return -EINVAL;
>    423  
>    424          if (copy_from_user(&add_arg, arg, sizeof(add_arg)))
>    425                  return -EFAULT;
>    426  
>    427          if (!IS_ALIGNED(add_arg.offset, PAGE_SIZE) ||
>    428              !IS_ALIGNED(add_arg.src, PAGE_SIZE))
>    429                  return -EINVAL;
>    430  
>    431          if (add_arg.length & (PAGE_SIZE - 1))
>    432                  return -EINVAL;
>    433  
>    434          if (add_arg.offset + add_arg.length - PAGE_SIZE >= encl->size)
>    435                  return -EINVAL;
>    436  
>    437          if (copy_from_user(&secinfo, (void __user *)add_arg.secinfo,
>    438                             sizeof(secinfo)))
>    439                  return -EFAULT;
>    440  
>    441          if (sgx_validate_secinfo(&secinfo))
>    442                  return -EINVAL;
>    443  
>    444          for (c = 0 ; c < add_arg.length; c += PAGE_SIZE) {
> 
> If the user passes in an "add_arg.length" value of zero then "ret" isn't
> initialized.

Thanks, I submitted a fix:

https://lore.kernel.org/linux-sgx/20201202162200.88941-1-jarkko@xxxxxxxxxx/

/Jarkko



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux