From: Jarkko Sakkinen <jarkko@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: linux-sgx@vger.kernel.org
Subject: Re: [bug report] x86/sgx: Add SGX_IOC_ENCLAVE_ADD_PAGES
Date: Wed, 2 Dec 2020 18:23:49 +0200 [thread overview]
Message-ID: <20201202162349.GB87890@kernel.org> (raw)
In-Reply-To: <X8ehQssnslm194ld@mwanda>
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@kernel.org/
/Jarkko
prev parent reply other threads:[~2020-12-02 16:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-02 14:14 [bug report] x86/sgx: Add SGX_IOC_ENCLAVE_ADD_PAGES Dan Carpenter
2020-12-02 16:23 ` Jarkko Sakkinen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201202162349.GB87890@kernel.org \
--to=jarkko@kernel.org \
--cc=dan.carpenter@oracle.com \
--cc=linux-sgx@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox